Jump to content

Recommended Posts

Hi all

 

I have a members login page which is secured with SESSIONS, when you login a SESSION is created and that's what determins if you should see member content or not.

 

I want to try and keep the member logged in for the MAXIMUM time possible, so even when they close a browser a re-open, it would remember them and they should not have to log in again.

 

What do you feel is the best way to do this so that I can maximise the length of time they are logged in.

 

Any advice would be ace

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/133176-keeping-logged-in-with-sessions/
Share on other sites

However it's not the best idea to extend the session for a long period of time, For example if the user is at a Internet Cafe, then the next person who uses the computer they were on, will still have access to the previous users account. If they didn't clear there cookies.

Thanks Guys, I thought cookies were the way to do it but just wanted to see what you thought.

 

I've seen and tried many cookie stay logged in scripts, but never really managed to get one working well, do you know of any good tutorials on setting this up.

 

Thanks

Thanks, I have managed to get the following, but I get "Parse error: syntax error, unexpected T_STRING in C:\web\test.php on line 5" when its run, any ideas?

 

$_POST['username'] = 'xx';
$_POST['pass'] = 'yy';
$hour = time() + 60*60*24*1000
setcookie("ID_my_site", $_POST['username'], $hour); 
setcookie("Key_my_site", $_POST['pass'], $hour); 

print $_COOKIE['ID_my_site']; 
print $_COOKIE['Key_my_site'];

 

Thanks

Yes, thanks, managed to see that in the end.

 

I am now using

 

$timeset = time() + 60*60*24*1000;
setcookie("cookie_ef_username", $_POST['email'], $hour);
setcookie("cookie_ef_password", $_POST['password'], $hour);

 

Which works fine until the browser is closed and then it seems to loose the cookie data, why could that be?

 

Thanks

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.