0

in Php, there is a script, runs occasionally:

session_start();
$_SESSION['x']++;

and something to use it, backround-service, runs "forever":

session_start();
do
{
    echo $_SESSION['x']; // never gets updated!
} while(true);

the problem is, the echo echoes the same result, like it never gets updated. But both are running. Maybe sessions should be reloaded somehow?

John Smith
  • 6,129
  • 12
  • 68
  • 123
  • 2
    Does this answer your question? [How do PHP sessions work? (not "how are they used?")](https://stackoverflow.com/questions/1535697/how-do-php-sessions-work-not-how-are-they-used) – ArSeN Jun 04 '22 at 21:43
  • 2
    Have you tried calling [`session_reset()`](https://www.php.net/manual/en/function.session-reset.php) inside the `do { ... }` loop? – kmoser Jun 05 '22 at 03:20
  • I tried, but doesnt work, it "kills" the session. If I do "session_start();session_write_close();" then it works – John Smith Jun 05 '22 at 15:16

0 Answers0