添加会话超时


Adding session time out

<form name="form2" method="post" action="adminloginphp.php">
  <tr align="center">
    <td height="26" colspan="2">Login Page<br />
<b><font color="#FF0000"> <?php //echo $log; ?></font></b>
    </td>
  </tr>
  <tr>
    <td>Staff ID</td>
    <td><input name="staff_id" type="text" /></td>
  </tr>
  <tr>
    <td><label for="textfield">Password</label></td>
    <td><input type="password" name="staff_password" id="textfield" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="button" id="button" value="Login" /></td>
  </tr>
</form>
    >Above is my html and below is my php.
<?php
$con = mysql_connect("localhost","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("medical", $con);
if(isset($_POST["button"]))
{
$result = mysql_query("SELECT * FROM staff
WHERE staff_id='$_POST[staff_id]' and staff_password='$_POST[staff_password]'");
if(mysql_num_rows($result)==1)
{
$log =  "Login failed";
}
else
{
            header("Location: http://localhost/AB%20Medical%202/adminhome.php");       //redirect them to the main page whatever your login in page is if they enter wrong   username and password
}
}
mysql_close($con);
?>

我试图将会话超时添加到我的登录页面。但我不确定该怎么做。这是我的php登录名和我的html。有没有人对我的问题有一个简单的解决方案。我研究过网络,但似乎都非常复杂。另外,我是否需要在管理员使用的每个页面中添加会话超时,或者我可以在此登录页面中添加会话超时。

您可以在php.ini文件配置上配置它:

session.cookie_lifetime = X;

http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime