Jump to content

[SOLVED] User login time..


phpSensei

Recommended Posts

How can I register a session for a certan amount of time?

 

I have registered the user first, but then I want the user to be logged in evertime he or she comes to my website...

 

how?

 

thanks for any help..

 

here is my code

 

include("connect1.php");

$username=mysql_real_escape_string($_POST['username']);
$password=md5($_POST['password']);

$rec=mysql_query("SELECT * FROM member WHERE username='$username' AND password = '$password'");
$rec2=mysql_fetch_array($rec);

if(empty($username) || empty($password)){

die(header("Location: http://localhost/phpROK/index.php?page=home&t=3"));

}
elseif(($rec2['username']==$username)&&($rec2['password']==$password)){

session_start();

$_SESSION['username'] = $_POST['username'];

header("Location: http://localhost/phpROK/index.php?page=home");

}

else

header("Location: http://localhost/phpROK/index.php?page=home&t=1");

?>

Link to comment
Share on other sites

If you want the user to be logged in whenever they come to your website, look into cookies. Sessions are destroyed when the browser is closed, therefore, if you just use sessions, a user will have to log in each time they come to your website after closing their browser.

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.