Jump to content

Sessions And Cookies To Log Into A Website


kevinkhan

Recommended Posts

Does anyone know any good tutorials or examples on using cookies to store session ids.

 

i want to store username and password in a session and want to store the session id in a cookie and when a user comes back to the site i want the website to remember the session.

 

At the moment i am only using sessions and when i close the browser i have to re enter my user name and password to gain access to the site.

 

Any ideas on how to do this?

Link to comment
Share on other sites

You shouldn't expect a session to last longer than one browser session, since you would need to extend the session garbage collection maxlifetime setting to get the session data files to persist for the same amount of time you have set the session id cookie to persist. This would leave a session data file on the serve for every logged in user for the longer amount of time that you have chosen.

 

A 'remember me' feature normally works by generating a unique id (similar to a session id), then store that id in a cookie and store it in the user's row in your user table. When someone visits your site and they have a 'remember me' cookie, with a properly formatted unique id in it, you use the unique id from the cookie to find the corresponding row, if any, in the user table to identify who the visitor is.

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.