Jump to content

Login Timeout


dennismonsewicz

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.