-
Notifications
You must be signed in to change notification settings - Fork 1
/
first.php
47 lines (45 loc) · 1.12 KB
/
first.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
45
46
47
<?php
session_start();
if(!isset($_SESSION['isLoggedIn']) || !($_SESSION['isLoggedIn']))
{
//code for authentication comes here
//ASSUME USER IS VALID
$_SESSION['isLoggedIn'] = true;
/////////////////////////////////////////
$_SESSION['timeOut'] = 5;
$logged = time();
$_SESSION['loggedAt']= $logged;
showLoggedIn();
}
else
{
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'Page 1. 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="second.php">Go to second page</a></p>';
echo'<br/><br/><br/><p><a href="">Back to article</a></p>';
echo'</body>';
echo'</html>';
}