forked from ripasaha/session-timeout-alert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
second.php
44 lines (43 loc) · 1.04 KB
/
second.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
session_start();
if(!isset($_SESSION['isLoggedIn']) || !($_SESSION['isLoggedIn']))
{
//user is not logged in
// simply redirect to index.html
session_unset();
header("Location:index.html");
}
else
{
// user is logged in
require 'timeCheck.php';
$hasSessionExpired = checkIfTimedOut();
if($hasSessionExpired)
{
session_unset();
header("Location:index.html");
exit;
}
else
{
$_SESSION['loggedAt']= time();// update last accessed time
showLoggedIn();
}
}
function showLoggedIn()
{
echo'<html>';
echo'<head>';
echo'<script type="text/javascript" src="ajax.js"></script>';
echo'</head>';
echo'<body>';
echo'<p>';
echo'Page2. User is logged in currently.Timeout has been set to 5 seconds. If you stay inactive for more then 5 seconds, you will be logged out automatically and redirected to home page.';
echo'</p>';
echo'<br/>';
echo'<p><a href="first.php">Back to first page</a></p>';
echo'<br/><br/><br/><p><a href="">Back to article</a></p>';
echo'</body>';
echo'</html>';
}
?>