Answer the question
In order to leave comments, you need to log in
Why is session_id reset in wordpress site?
There is a site on wordpress (I don't know if it matters). Previously, everything was in order, but suddenly sessions began to act up: data between pages was not saved. The study showed that the session_id is reset (each time a new one when the page is updated):
var_dump(session_id());
at the same time, session files are also created new each time, and the old ones are not deleted.
Moreover, this bug is unstable: it can disappear and appear when changing pieces of code that are not directly related to sessions. For example, at one time adding this piece of code to functions.php worked, and I have no idea why (It definitely helped: I checked it on different browsers. If you remove this piece and open it on a new browser or computer, the bug returned. If you add it again, it starts Remove again and open on an already used browser - it did not stop working):
if (!isset($_SESSION["test2"])) {
echo '<script></script>';
$_SESSION["test2"] = 1;
}
ini_set('session.cookie_domain', '***.***.ru');
ini_set('session.use_trans_sid', 1);
session_set_cookie_params(36000, "/", "***.***.ru", false, false);
session_start();
Answer the question
In order to leave comments, you need to log in
There was a big high on this topic recently on reddit.
From it, I learned that
1. there is at least 1 special WordPress hosting that kills PHP sessions
2. WordPress does not use PHP sessions, you are not advised
3. if your WordPress site uses sessions, it means you are using a plug-in from shit code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question