G
G
graf452312019-03-19 12:57:48
PHP
graf45231, 2019-03-19 12:57:48

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

1 answer(s)
S
Stalker_RED, 2019-03-19
@graf45231

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 question

Ask a Question

731 491 924 answers to any question