How to do a session time out in php or processmaker(BPM)?
I refered most forum and wikis but that didn't solved my problem.
Please let me know.
How to do a session time out in php or processmaker(BPM)?
I refered most forum and wikis but that didn't solved my problem.
Please let me know.
On ProcessMaker you have to change the following parameters on your php.ini in order to modify the session time out
This will work from version 2.5RC1 (Release Candidate) which is available to be downloaded on the ProcessMaker sourceforge page
Hope this also helps you.
Store the last time the user made a request
<?php
$_SESSION['timeout'] = time();
?>
In subsequent request, check how long ago they made their previous request (10 minutes in this example)
<?php
if ($_SESSION['timeout'] + 10 * 60 < time()) {
// session timed out
} else {
// session ok
}
?>
Extracted from here
Include this code in the start of your php scripts:
<?php
if(!isset($_SESSION)){@session_start();}
if (isset($_SESSION['timeout']) and $_SESSION['timeout'] + 1800 < time()) {
session_unset();
session_destroy();
} else {
$_SESSION['timeout'] = time();
}
?>
The first line checks if there is a session, and if there is no session it creates it.
The @ sign in front of the session_start() is to suppress any warnings or notices that the session_start() might throw. Nothing important for this code at all, and you can remove it.
The next line checks if the $_SESSION['timeout'] variable exist and if it contains a value more than 30 minutes in to the past from the current time.
The first time you run the script it will not exist, so if you check its value when it does not exist it will give you a notice or warning message if this is enabled in your php.ini file.
If it does not exist we skip to the else and have it created, and we add the current time().
Now the value of 1800 is 30 minutes in seconds. 30 * 60 is another common way to write this to make it easier to read.
If the if is true, the user have been inactive for more than 30 minutes. If it is less than 30 minutes or the first time the script is running, it will skip to the else and update the timeout variable.