PHP XAMP session_status() is always 1?

邮差的信 提交于 2021-02-08 11:28:26

问题


session_status() keeps returning 1 (PHP_SESSION_NONE) every time I visit localhost page. I know storing variables, session_start() and session_destroy() work because of the files in c:\xamp\tmp (defined in php.ini)

But why doesnt it register as session in code?

if (session_status() === PHP_SESSION_NONE) {
    session_start();
    echo session_status();
} else{
    echo "active";
}

Any help would be appreciated, thank you


回答1:


we mostly use isset for condition on session variable

if(isset($_SESSION['var'])){
    echo "Welcome". $_SESSION['var'];
}

maybe its helpfull for you :)



来源:https://stackoverflow.com/questions/60083271/php-xamp-session-status-is-always-1

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