Khalil
IDK
Hello everyone, so it's been a very longtime since i have posted anything on this section, so decided to do small thread and share a small script i'm currently using for
This script works as follows, you put the code into any page you like (a page where the session is started) and then set a certain amount of seconds, once that amount of seconds is reached the sessions is automatically destroyed.
The code is:
As, you saw this was a very simple code, nothing hard, hope it will come handy for you & thank you for your time.
- Khalil
You must be registered for see links
.This script works as follows, you put the code into any page you like (a page where the session is started) and then set a certain amount of seconds, once that amount of seconds is reached the sessions is automatically destroyed.
The code is:
PHP:
$inactive = SET THIS INTO SECONDS;
if (isset($_SESSION["timeout"])) {
$sessionTTL = time() - $_SESSION["timeout"];
if ($sessionTTL > $inactive) {
session_destroy();
header("Location: /logout.php"); <-- you can change this page to any page you want.
}
}
$_SESSION["timeout"] = time();
As, you saw this was a very simple code, nothing hard, hope it will come handy for you & thank you for your time.
- Khalil