Answer the question
In order to leave comments, you need to log in
Why is expires not set for a php session?
I changed the config like this:
After that I set the cookie in the script, then I redirect to another page and output the cookie. It is displayed, but when I open a new tab. then the server writes an error that the field in $_SESSION was not found.
And this is on all browsers with default settings. No matter how I tried, browsers still write that the cookie expires When the browsing session ends
In short, this is what it doessession_set_cookie_params(1200);
Set-Cookie: PHPSESSID=ik4cq67182rugi7k0ftv9kebdh; expires=Sat, 26-Oct-2019 13:20:55 GMT; Max-Age=1200; path=/
Answer the question
In order to leave comments, you need to log in
When setting the cookie, the "Date:" string from the HTTP response header still matters. It tells the browser the server's current time. Next, the browser subtracts the "Date:" value from the expires cookie and learns from the difference how many minutes this cookie can be used. You can check this by looking at the end time of the cookie in the browser itself, it will differ from the server one (if the time zones are different) ...
In a new tab (with the "missing" cookie) which page is loading? Does it have session_start()?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question