Test if session is started

折月煮酒 提交于 2019-12-10 13:33:35

问题


How do you test to see if sessions are on. This is not the way...

session_start();
if(isset($_SESSION)) {
    echo "sessions ON<br>";
}
else{
    echo "sessions OFF<br>";
}

session_destroy();
if(isset($_SESSION)) {
    echo "sessions ON<br>";
}
else{
    echo "sessions OFF<br>";
}

回答1:


Try this:

if(session_id())

http://php.net/manual/en/function.session-id.php




回答2:


session_start() itself will return boolean TRUE if the session was started successfully, boolean FALSE if not.



来源:https://stackoverflow.com/questions/3357740/test-if-session-is-started

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!