OK, to make sure I understand:
When testing to see if a session has timed out, would you also have to check if the 'sess_*' file (in the specified PHP.ini temp. directory) was available as well?
In other words, once the Zend engine has ran gc right before every session initialization; the 'sess_*' file was unavailable because it was deleted during gc.
Thus, if you where trying to check the 'sess_*' file's last modified time with filemtime(), you would get an E_WARNING because the file is not there anymore.
With that said, would the following logic work?
/*
For testing purpose only
Run gc 99% of the time after 10 minutes
*/
ini_set('session.gc_probability', '99' );
ini_set('session.gc_divisor', '100' );
ini_set('session.gc_maxlifetime', '600');
session_start();
$sid = session_start();
$sid_path = '/tmp/sess_'.$sid; //UNIX - SUN Solaris
if (file_exists($sid_path))
{
$s_timeout = (int) date("i", filemtime($sid_path));
if ((int) $s_timeout > 30) {
$_SESSION=array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
}
}
else
{
$_SESSION=array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
}