Is it possible to set unlimited session timeout in php

I have my own website that requires a login to view more information. My problem is that when the user logs in, the session is started for a limited time, which is already defined in the php.ini file. I want unlimited session time when user logs in. I've already used the ini_set () function ie:

ini_set("session.gc_maxlifetime",720000); 
ini_set('session.gc_probability',1); 
ini_set('session.gc_divisor',1); 

      

which temproraily sets the session time php_ini value. but it doesn't work.

Is there something I am doing wrong?

Please help me to solve this problem.

+3


source to share


2 answers


Set session.gc_probability

to 0 before starting a session. This will give the garbage collector a 0% chance to delete session data. You must do this in all applications that use the same session storage location.



+1


source


You can try doing it like this:

<?php

 ini_set('session.gc_maxlifetime', 30*60);
 session_start();

 ?>

      

The second parameter is the number of seconds after which the data will be considered "garbage" and potentially cleaned up.



Also check this one for more info.

Of course, you can customize the rooms to suit your needs.

0


source







All Articles