Jump to content

session timout after 10 days.


zohab

Recommended Posts

Hi,

 

In my site when user login then username and password stored in session

and if user does not close browser and be login in the site

 

If my session is timeout then user will be logout .

 

I want to set session timeout to be 10 days

 

after 10 days session will be timeout

 

 

Link to comment
Share on other sites

Hi Bricktop ,

 

I am using session.

I have to do the settings in php.ini file through ini_set function

 

but which one?

 

ini_set('session.gc_maxlifetime',30);

ini_set('session.gc_probability',1);

ini_set('session.gc_divisor',1);

ini_set('session.cache_expire ',180);

 

Link to comment
Share on other sites

Hi zohab,

 

Just re-read your orginal post, the 'session.gc_maxlifetime' parameter is not used to set session timeouts, it's the Garbage Collection timeout for session file deletion.  I thought this is what you meant when I first read your post, sorry about that!

 

You will need to use the session.cookie_lifetime parameter for what you're asking, i.e.:

 

ini_set('session.gc_maxlifetime',30);
ini_set('session.cookie_lifetime', 864000);
ini_set('session.gc_probability',1);
ini_set('session.gc_divisor',1);
ini_set('session.cache_expire ',180);

 

Hope this helps.

Link to comment
Share on other sites

You need to set both the session.gc_maxlifetime and the session.cookie_lifetime to the longer value, because you need both the session data file on the server and the matching cookie from the browser in order to resume a session.

 

If you are on a shared web server and you are using the default tmp folder for the session save path, you must also set the session save path to a private folder within your account's disk tree. When you use the default tmp folder on a shared web server the SHORTEST session.gc_maxlifetime setting of all the scripts of all the accounts running on the web server will WIN and cause you session data files to be deleted when garbage collection runs. When you set the session save path to be to a private folder, you session data files will only be affect by your session settings.

 

You must also set your session settings before EVERY session_start() statement or the master values in the php.ini will be used. It is best to globally set them in a .htaccess file (when php is running as an Apache Module) or in a local php.ini (when php is running as a CGI application.)

 

Session variables are intended to be used for one single browser session. For a "remember me" type of login, you should actually use cookies to save a unique identifier, not a session.

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.