Answer the question
In order to leave comments, you need to log in
[Solved] PHP and session loss on session_regenerate_id()
In short, we take the code:
<?php session_start(); if (!isset($_SESSION['a'])) { $_SESSION['a'] = 0; } ob_start(); print $_SESSION['a']; $_SESSION['a']++; session_regenerate_id(true); ?>
Answer the question
In order to leave comments, you need to log in
Apparently, a race condition occurs here due to the many parallel requests trying to write their data to the session file. Add before session_regenerate_id(true);
a call session_write_close();
read, by the way, the description to this function.
In general, to prevent this from happening, session_regenerate_id(true);
they usually put it right after the call session_start();
.
With your synthetic example, I succeeded in both cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question