Jump to content

Session without expiration


LamivNahdus

Recommended Posts

Hello,

        I need to create a session which will not expire at all. I have searched the php.net site in its documentation. But iam not able to get the point clearly. I know that sessions will expire after some frequent initialization through session_start(). But how to avoid this?

My session should not expire so that user can be signed in forever.

Please help me by providing a good explanation...

Thank you

Link to comment
https://forums.phpfreaks.com/topic/102477-session-without-expiration/
Share on other sites

Sessions are intended to propagate data between pages on your site for the duration of one visit. They are not intended to hold data forever (the maximum time you can set using php is the year 2038.)

 

You can make a session last until 2038 by setting the session.cookie_lifetime, the session.gc_maxlifetime, and if on a shared server, setting the session.save_path to be a private folder in your account space so that garbage collection running due to other php scripts won't delete your session data files.

 

However, the proper way to "remember" that a visitor is logged in between visits, is to use a regular cookie with an expire time of your choice to hold a unique identifier (not their user name as that can be easy to guess) that you store in your database in their user record and remember that they are logged in using a field in your database.

Thank you so much for your explanation.

Bu how can i change the values you have said? I used .htaccess file with following configuration:

php_value session.cookie_domain .example.com
php_value session.name sess

But this produced a 500 Internal server error. What to do?

There is also one more file inside my hosting web directory named php.ini. I added two lines into that file as

session.name = sess
session.cookie_domain = .example.com

But the changes are not affected, when i used phpinfo() function.

What to do? How to use php.ini in my web directory?

Thank you...

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.