1this is a session timeout i use.
2
3when the session is initially created:
4
5session_start();
6$_SESSION['LAST_ACTIVITY'] = time();
7the function that gets called in other pages to update the session timeout when navigating to new pages
8
9function check_timeout($timeout, &$SESSION)
10 {
11 if (isset($_SESSION['LAST_ACTIVITY']))
12 {
13 if((time() - $_SESSION['LAST_ACTIVITY']) > $timeout)
14 {
15 end_session($SESSION);
16 }
17 $_SESSION['LAST_ACTIVITY'] = time();
18 }
19 else
20 {
21 end_session($SESSION);
22 }
23 }
24i have a separate function (end_session()) to end a session. the & in the parameter allows the session to be updated by the function.
25
26on each page, i call:
27
28session_start();
29check_timeout($timeout, $SESSION);