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
https://forums.phpfreaks.com/topic/63579-solved-user-login-time/
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.

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.