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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.