A
A
Albert Kazan2018-03-28 08:34:24
PHP
Albert Kazan, 2018-03-28 08:34:24

Why are cookies being reset?

Used to authorize cookies with php sessions. But as I close the browser, the cookie, like the session, disappears. Through the back I set them a lifetime of 2 days.
The code has already been used in two projects for authorization, but this time something does not work. Through the browser I check the lifetime, everything is correct, but when closed it is still destroyed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mletov, 2018-03-28
@mletov

Tested on different computers in different browsers?
Is the behavior the same locally and on hosting?
1) There is a setting in the browser "Destroy cookies after exiting the browser"
2) Maybe there is not enough disk space on the computer from which you are accessing
3) Google what are the settings in .htaccess/php.ini related to cookies
It is possible that apart from

php_value session.cookie_lifetime 1200
php_value session.gc_maxlifetime 1200

there is something else
I had such a problem, I made several sites on the same code, everything worked, and then cookies stopped being hung up. It turned out that the hoster changed the default value in php.ini of some of these parameters php.net/manual/en/session.security.ini.php (I don’t remember which ones now).
Walk through them. If it works locally, but does not work on the external one, then compare the local configuration with the external one. Especially take a look at this session.use_only_cookies
setting 4) I remember that one user had cookies crashing all the time in different browsers. The only thing that helped was replacing the computer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question