How do i check if session_start has been entered?

前端 未结 10 1531
走了就别回头了
走了就别回头了 2020-12-09 09:00

I have a third party script and was wondering how I can check with PHP if session_start() has been declared before doing something?



        
10条回答
  •  离开以前
    2020-12-09 09:44

    I suppose you could use the session_id function :

    session_id() returns the session id for the current session or the empty string ("") if there is no current session (no current session id exists).

    Or maybe testing whether $_SESSION is set or not, with isset, might do the trick, as it should not be set when no session has been started -- you just have to hope that nothing assigns anything to $_SESSION without starting the session first.

提交回复
热议问题