P
P
Pegasso2019-10-26 15:51:35
PHP
Pegasso, 2019-10-26 15:51:35

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 does
session_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

1 answer(s)
A
AUser0, 2019-10-26
@AUser0

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 question

Ask a Question

731 491 924 answers to any question