Jump to content

cookies and session variables


simply07

Recommended Posts

hello i am trying to keep users logged into my site once they close the browser.

 

I was wondering if there was an easy way of converting cookie into sessions variables or vice versa.

The thing is i am working on a large website and I was asked to keep users logged in once they close the browser. I know that session variables dies once the browser is closed so i was hoping to use cookies to store their info so when they reopen the browser they are still remembered

 

Any help would be truly appreciated.

Steph

 

 

Link to comment
https://forums.phpfreaks.com/topic/112035-cookies-and-session-variables/
Share on other sites

the best way i can think of is to generate a random hash (using md5 or such) every time the load a page (so it keeps rotating). store this value in a cookie and in your users table for your site. then, when they access the page again, check for that value and automatically log them in.

 

fyi, this is a HUGE security risk, as cookies can be manually set by the user. as long as you keep it as a random hash, and keep changing it, it should be relatively reliable. obviously though, once the user is in, if they want to access sensitive info or change passwords, etc, you should make them enter their password

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.