Why PHP session is deleted on page reload?

戏子无情 提交于 2019-12-02 09:32:07

问题


So I've this problem that, when I'm on the page not doing anything for some time, after I reload the page $_SESSION is cleared. I checked the code and it does not have any unset() functions or anything else what could clear the $_SESSION variable. Any ideas why is it happening?

Edit: In case if I want to make the session live till the browser is closed what should I do? I don't understand it as the gc checks if session is expired on session_start, but I can't modify the session data before calling session_start, so modifying the session data after calling session_start would result in expired session anyway?

I've the session.cookie_lifetime set to 0 by default, session.gc_maxlifetime, session.gc_divisor, session.gc_probability are set to their default values too.


回答1:


Have you put de session_start() at the beginning of every page?



来源:https://stackoverflow.com/questions/4889532/why-php-session-is-deleted-on-page-reload

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