Jump to content

Odd Session Behavior


Asperon

Recommended Posts

<?php
session_start();

if(!isset($_SESSION['time'])){
  $_SESSION['time'] = time();
}

echo $_SESSION['time'];

?>

For some reason, this code will resave time() in the $_SESSION['time']. It does not stay set
between refreshes. I was using date earlier, but realized that $_SESSION could not hold an
object so I started using time instead.

Also, later, at the end of the script I reset the $_SESSION['time'] based on the last saved data
entry in my MySQL table, which is also an integer, so it should still be set.

Any ideas?

P.S. Let me know if you need to see the whole script

Link to comment
https://forums.phpfreaks.com/topic/163081-odd-session-behavior/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.