Jump to content

[SOLVED] What is the best way of having persistent session cookie and server-side session


anupamsaha

Recommended Posts

Hello,

 

My development team is working on a login form that suppose to have a "remember me" feature. I would like to know what are the best practices involved in implementing a persistent login / session cookie with a server-side session file with a longer lifetime.

 

Thanks in advance for your suggestions.

 

Sessions and cookies are two different (though interconnected) things.

 

Sessions persist data whilst you are active on a webpage. Cookies are used to persist data between visits.

 

I know that session and cookies are two different things. But, when it comes to session_start(), a file sess_{session_id} in the server and a corresposding cookie (with a name session_id) is generated in client's PC. So, I wanted to know about the best practices to enhance the session lifetime that would overcome the session garbage collection method. So, I wanted to know if I increase the session garbage collection time and session lifetime, what will be the effect on the server as we will have lots of session files generated in the server.

 

I also studied that PHP can be compiled witth "mm" directive while a site deals with too many session files.

 

Am I making sense?

 

A session is designed to last for one browser session, but yes, you can extend it and make it persist between browser sessions (the php.net session handling documentation indicates how), but the best way to create a "remember me" feature is to use a cookie to identify the visitor.

A session is designed to last for one browser session, but yes, you can extend it and make it persist between browser sessions (the php.net session handling documentation indicates how), but the best way to create a "remember me" feature is to use a cookie to identify the visitor.

 

Thanks PFMaBiSmAd.

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.