phpSensei Posted August 6, 2007 Share Posted August 6, 2007 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 More sharing options...
kyleldi Posted August 6, 2007 Share Posted August 6, 2007 SESSION['length'] = time() + 1400; Maybe? (replace 1400 w/ number) Link to comment https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316824 Share on other sites More sharing options...
phpSensei Posted August 6, 2007 Author Share Posted August 6, 2007 Thanks Bro... Link to comment https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316888 Share on other sites More sharing options...
phpSensei Posted August 6, 2007 Author Share Posted August 6, 2007 Is this Good? $_SESSION['username'] = $_POST['username']; $_SESSION['length'] = time() + 1400; Link to comment https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316890 Share on other sites More sharing options...
phpSensei Posted August 6, 2007 Author Share Posted August 6, 2007 sorry for the triple posting, but it didnt work. Link to comment https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316896 Share on other sites More sharing options...
The Little Guy Posted August 6, 2007 Share Posted August 6, 2007 is something like this what you are looking for??? http://snippets.tzfiles.com/snippet.php?id=39 Link to comment https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316898 Share on other sites More sharing options...
GingerRobot Posted August 6, 2007 Share Posted August 6, 2007 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 https://forums.phpfreaks.com/topic/63579-solved-user-login-time/#findComment-316900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.