Checking for PHP session without starting one?

后端 未结 3 666
感情败类
感情败类 2021-02-12 20:30

Is it possible to check for a session with out starting one?

The reason that I ask is, the app I am developing has an integrated admin interface. So when an admin is logg

3条回答
  •  遇见更好的自我
    2021-02-12 20:54

    You'd be wanting session_id(), which returns empty string if no session is defined.

    The documentation indicates that empty string (which is not "nothing") is returned if no session is started.

    As the 2014 comments indicate (I wrote this answer in 2009), there is the possibility that a session could start if there is a cookie with a session id stored in it that could be picked up by session_start().

    As of PHP 5.4.0, we now have session_status() but this didn't exist in 2009.

提交回复
热议问题