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);
?>

Im trying to add a session time out to my login page .But im unsure on how to do it.Here is my php login and my html.Does anyone have a simple solution to my problem.I have researched the web but all seem very complex.Plus do i need to add the session timeout in every page the admin uses or can i just have in this login page.

Answers


You can configure it on you php.ini file configuration with:

session.cookie_lifetime = X;

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


Need Your Help

python script for RaspberryPi to connect wifi automatically

python wifi raspberry-pi

I want to operate a WiFi dongle with RaspberryPi, (it's like a CPU without built-in WiFi). I need to write a python script which automatically scan for WiFi networks and a connection need to be

MacVim set as default text editor: How to set files to open in a new tab as opposed to a new window?

text editor default tabs macvim

I've set MacVim as my default text editor, and when I double click files it opens up a new window. Is there a way to set it to open up in a new tab instead?