There are a lot of Stack Overflow questions which advise using separate cookies to keep session parameters, but I don’t want to store any additional cookies on the client side.
At the moment I have a new session with empty session parameters after each browser restart.
Is there any way to keep the PHP session active after each browser restart?
The site is very simple without a database. I’m storing all data in $_SESSION.
Advertisement
Answer
I guess, you use session_start function to start a new session. If I am correct then you have default lifetime for PHPSESSID cookie with is equals to 0. Zero lifetime means that cookie is session cookies.
Session cookies are deleted when the current session ends. The browser defines when the “current session” ends, and almost all browses ends the session when the browse is closed.
You can try to set lifetime for session cookie with session_set_cookie_params function. The first input parameter is $lifetime which define lifetime of the session cookie, defined in seconds.
Just try to execute session_set_cookie_params(86400) before session_start and check if my answer is suitable for you.