redirect a user to a logout page if no action taken...
Posted: Sun Aug 27, 2006 2:56 pm
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.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
feyd wrote:A Javascript timeout or meta redirect could do it
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>