I cant seem to get my session to time out.
see below very simple code.
The start button starts session and below prints id and time till timeout. I’ve set it to 5 seconds, which it does display, but if you wait for more than 5 seconds and refresh it still shows the id and 5 seconds.
Am I missing something here?
<?php
echo <<<_END
<form method="post" action="">
<input type="hidden" name="start" value="yes"/>
<input type="submit" value="Start session"/>
</form>
_END;
if (isset($_POST['start']))
{
session_start();
ini_set('session.gc_maxlifetime', 5);
ini_set('gc_probability', 100);
ini_set('gc_divisor', 100);
}
echo session_id();
echo "<br>";
echo ini_get('session.gc_maxlifetime');
?>
From the php documentation:
To use cookie-based sessions, session_start() must be called before outputing anything to the browser..