note 86638 deleted from session.security by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:46:17 +0000 |
| Subject: | note 86638 deleted from session.security by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215298@lists.php.net to get a copy of this message | ||
Note Submitter: JonathanFeller at NOSPAMgmx dot ch
----
Perhaps, you would also like to timeout a session after some idle time. I noticed that
session.gc_maxlifetime is not suitable for this. So I used this code to do the job:
<?php
if (!isset($_SESSION['timeout_idle'])) {
$_SESSION['timeout_idle'] = time() + MAX_IDLE_TIME;
} else {
if ($_SESSION['timeout_idle'] < time()) {
//destroy session
} else {
$_SESSION['timeout_idle'] = time() + MAX_IDLE_TIME;
}
}
?>