Answer the question
In order to leave comments, you need to log in
How to set session ID?
There is a site with a shopping cart and so on. All data is stored in the session, and accordingly the identifier is passed to cookies. But if I add a product to the cart and then turn off the browser and launch that site again, a new session is created with a new identifier. Is it supposed to be like that? It should take PHPSESSID from cookies and start the required session depending on it.
The site itself does not find the desired session, I decided to prescribe it before session_start(); such line session_id($_COOKIE['PHPSESSID']);
but still nothing changes. Moreover, if you force the old ID to be entered in the browser, then the entire basket will be loaded correctly, that is, the session is stored on the server.
The following parameters are also set:
@ini_set('session.gc_maxlifetime', 86400); // 86400 = 24 hours
@ini_set('session.cookie_lifetime',
Here is a link to the site: optom-toy.ru
Answer the question
In order to leave comments, you need to log in
Here's the reason:
Make sure the session.cookie_lifetime setting is applied BEFORE session_start()
Or better yet, set it in php.ini or directly at the entry point.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question