redirect a user to a logout page if no action taken...
Moderator: General Moderators
redirect a user to a logout page if no action taken...
Can there be a way that if the user hasn't dealt with a page for about 30 minutes could be sent to a logout page where the session is finished.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
A Javascript timeout or meta redirect could do it, but I wouldn't go about this in that fashion.
viewtopic.php?t=53558 may be of interest.
viewtopic.php?t=53558 may be of interest.
-
mikesmith76
- Forum Commoner
- Posts: 34
- Joined: Fri Aug 25, 2006 7:10 am
- Location: Manchester, UK
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If you are checking for a current session (like you should be doing) then this should be easily handled for every page load. But it won't be discovered until the user submits a page request to the browser. If you are looking to do this real time (like it has been 30 minutes, the page will now log you out) then you have to use a client side technology.
The solutions that fyed posted have been tried but they don't seem to work, and Mr Everah I don't want that the user should be specially loggedout automatically if 30 minutes are gone, I'm just saying that if the page is open for 30 minutes and there has been no traffic what so ever than on clicking something after 30 minutes on that page the user should be sent to the login page,.................any solution on that is welcomed..........
Code: Select all
<?
session_start();
if(!isset($_SESSION['userId']))
{
header("Location: userlogin.php");
}
else
{
$userId = $_SESSION['userId'];
$userName = $_SESSION['userName'];
$userPassword = $_SESSION['userPassword'];
}
?>Code: Select all
<html>
<head>
<title>User Activities</title>Code: Select all
//This is the point where I am using the meta tags but it doesn't logout to the required page after the timeCode: Select all
<META HTTP-EQUIV="REFRESH" CONTENT="300;userlogout.php">
<!-- Fireworks MX Dreamweaver MX target. Created Fri Jan 06 16:18:49 GMT+0500 (West Asia Standard Time) 2006-->
</head>
<body bgcolor="#ffffff" WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0 TOPMARGIN=0>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="750">
<!-- fwtable fwsrc="1_1 copy.jpg" fwbase="1_1.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
<tr>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
<td><img src="images/spacer.gif" width="16" height="1" border="0" alt=""></td>
<td><img src="images/spacer.gif" width="710" height="1" border="0" alt=""></td>
<td><img src="images/spacer.gif" width="23" height="1" border="0" alt=""></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td> </tr>
<tr>
<td><img src="images/spacer.gif" width="1" height="221" border="0" alt=""></td>
<td colspan="3"><font face="Verdana"><map name="FPMap0">
<area href="index.php" shape="rect" coords="18, 179, 134, 217">
<area href="aboutUs.php" shape="rect" coords="159, 179, 275, 213">
<area href="help.php" shape="rect" coords="299, 180, 407, 214">
<area href="resources.php" shape="rect" coords="429, 180, 556, 218">
<area href="contactUs.php" shape="rect" coords="573, 181, 729, 213"></map><img border="0" src="images/Banner.JPG" width="750" height="221" usemap="#FPMap0"></font></td>
</tr>
<tr>
<td rowspan="2" colspan="2" background="images/1_1_r2_c1.jpg"> </td>
<td background="images/userScreen.jpg">
<p> <font face="Verdana"> Welcome, <?php echo strtoupper($userName); ?></font></p>
</td>
<td rowspan="2" background="images/1_1_r2_c4.jpg"> </td>
</tr>
<tr>
<td>
<p align="center">
<p align="center"><font face="Verdana" size="4">Pending Activity Forms</font>
<table id="table4" style="BORDER-COLLAPSE: collapse" borderColor="#111111" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tbody>
<tr>
<td width="100%">
<p align="right"><font face="Verdana"><span style="FONT-SIZE: 8pt; FONT-STYLE: italic"> Activity
Monitor</span></font> </p>
</td>
</tr>
</tbody>
</table>
<hr color="#000000" SIZE="1">
<form method="POST" action="userPa.php">
<b><font face="Verdana" size="2"> The Pending Activity Forms for "Code: Select all
<?php echo strtoupper($userName); ?>Code: Select all
" are given below: </font></b><br>
<font face="Verdana" size="2">Code: Select all
<?
// Coding for Pending Activites
$previousSunday = strtotime("previous sunday");
$prevSunday = date('Y-m-d', $previousSunday);
include ("include/database.php");
$link = mysql_connect($dbServer, $dbUser, $dbPassword);
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
else
{
mysql_select_db ("project", $link);
$query = "SELECT formId,date_format(frmDt, '%d %b %Y') AS formattedFrmDt FROM activityForm WHERE formStatus = 'pending' AND empId='$userId' AND frmDt>='$prevSunday'";
$result = mysql_query ($query, $link);
while ($query_data = mysql_fetch_array($result))
{
$formId = $query_data["formId"];
$frmDt = $query_data["formattedFrmDt"];
?>Code: Select all
<br>
<a href="activityForm2.php?formId=Code: Select all
<?echo "$formId";?>Code: Select all
<?
echo $frmDt;
?>Code: Select all
</a>
<br>Code: Select all
<?
}
mysql_free_result($result);
mysql_close($link);
}
?>Code: Select all
<p align="center">
<br><br>
<input type="submit" value="back" name="back">
<br><br><br><br><br>
<tr>
<td colspan="4"><font face="Verdana"><map name="FPMap1">
<area href="index.php" shape="rect" coords="71, 21, 123, 41">
<area href="aboutUs.php" shape="rect" coords="145, 19, 226, 39">
<area href="help.php" shape="rect" coords="252, 18, 300, 39">
<area href="contactUs.php" shape="rect" coords="325, 17, 426, 39"></map><img name="n1_1_r4_c1" src="images/1_1_r4_c1.jpg" width="750" height="49" border="0" alt="" usemap="#FPMap1"></font></td>
</tr>
</table>
</form>
</body>
</html>did you read the thread feyd posted? If you read it, you'll see that you need to store the last user activity (by means of a timestamp) in the session, and on each new page request you just check to see if a certain amount of seconds have passed, and if so, kill the session and redirect... c'mon you can do it! 
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You might have problems with the session.gc_max_lifetime default setting (24 minutes I blieve) if you are using timestamps and want the timeout to be 30 minutes. Although I would say that 30 minutes may be a little too long to leave a session unattended (unless you are doing lengthy content publishing or other things that require an excessive amount of time). I limit my unattended sessions to 10 minutes tops.