I am trying to expire a session when it a user has not use the site for a time, say 15 mins...
I have tried using something like this at the top of each page:
session_cache_expire(15);
session_start();
But that doesn't seem to do anything. Users who do nothing for 15 mins are still logged in.
Then I tried setting a timestamp in the session, and checking if that was less than current time + 15mins....
if ($_SESSION['time'] < time() + 900)
{
session_unset();
session_destroy();
}
session_start();
But this has 2 probs... firstly, if the user isn't logged in, there is no session to be destroyed! And secondly, you can't send things to the browser before calling the session_start.
SO..... is there an easy way to destroy a session after a certain amount of time? Because if it is automatically destroyed, then the next time the user loads the page, he/she won't be recognised. Bingo!
Any offers? Thanks in advance....
}