Here is a simple page I have:
<?php
session_start();
if(!isset($_SESSION['test'])) {
$_SESSION['test'] = time();
} else {
session_regenerate_id(true);
}
print_r($_SESSION);
?>
So it checks if session exists. If it does not exist, then it will set a value. In this example, it is time()
so we can see if it has changed or not.
If the session is set, we call session_regenerate_id(true)
but. It should keep showing the same time()
since we have already set it in the first place, but it keeps showing different times on each refresh. I've tried removing the "true" in the regenerate function but it still does not work.
Anyone can help?