dennismonsewicz Posted January 18, 2008 Share Posted January 18, 2008 I have a login script in place now for a company intranet, but I need to have a session timeout so after say like 30 minutes of no activity the user is logged out. Can anyone help with this? This is my login.php page: <p>To login, please fill out the form below with your given username and password</p> <div id="loginform"> <form name="form1" method="post" action="checklogin.php"> <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td>Username: </td> <td><input name="username" type="text" id="username" /></td> </tr> <tr> <td>Password: </td> <td><input name="password" type="password" id="password" /></td> </tr> <tr> <td colspan="2"><input type="image" src="../images/login.gif" class="submit" alt="Submit Changes" value="Login" /></td> </tr> </table> </form> </div> Do I need to pass a hidden input somehow recording the time of login? This is my checklogin.php page: ob_start(); include "includes/db_login.php"; // username and password sent from signup form $username = $_POST['username']; $password = $_POST['password'] $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $username, $password and redirect to file "login_success.php" session_register("username"); session_register("password"); header("location: http://intranet.healthresources.net/index.php"); } else { include "includes/header.php"; echo "<p>Wrong Username or Password</p>"; echo "<p><a href='index.php'>Try Again?</a></p>"; include "includes/footer.php"; } ob_end_flush(); All help is greatly appreciated, Dennis Link to comment https://forums.phpfreaks.com/topic/86688-login-timeout/ Share on other sites More sharing options...
drummer101 Posted January 18, 2008 Share Posted January 18, 2008 Alter your login script to include a cookie, set the cooke to expire after x minutes. (your auth script will have to check the validity of the cookie, is it there?) Link to comment https://forums.phpfreaks.com/topic/86688-login-timeout/#findComment-443028 Share on other sites More sharing options...
dennismonsewicz Posted January 18, 2008 Author Share Posted January 18, 2008 is there anyway you can include an example? Link to comment https://forums.phpfreaks.com/topic/86688-login-timeout/#findComment-443030 Share on other sites More sharing options...
drummer101 Posted January 18, 2008 Share Posted January 18, 2008 http://us3.php.net/setcookie Link to comment https://forums.phpfreaks.com/topic/86688-login-timeout/#findComment-443079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.