How can I set the session expiry time to 10 minutes for the whole of my site?
I cannot use the php.ini
as its on shared hosting.
Is there a global method I could use?
I don't think so.
You can save the timestamp of the last refresh of your website into a session and compare it with the current time on the next reload.
if(isset($_SESSION['expiretime'])) {
if($_SESSION['expiretime'] < time()) {
//logged out
}
else {
$_SESSION['expiretime'] = time() + 600;
}
}
//maybe add some login procedures and than execute the following line
$_SESSION['expiretime'] = time() + 600;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With