Increase the session time in shared hosting

1

As they are friends, it happened to someone else that the lifetime of the variable $ _SESSION does not last long enough and when you reload the page again asks the user to log in, someone knows how to increase the time of life. I tried my PHP code after the user data is valid

ini_set('session.gc_maxlifetime', time() + (60*60*4));
ini_set('session.cookie_lifetime', time() + (60*60*4));

and in the php.ini of the server I have placed the following:

session.gc_maxlifetime = 14400
session.cookie_lifetime = 14400

But still it does not work and the life time remains the same, I hope you can help me, thanks in advance.

    
asked by jantoni 09.09.2017 в 19:09
source

1 answer

1

I share the solution I found after trying so hard:

define('DURACION_SESION','7200'); //2 horas
ini_set("session.cookie_lifetime",DURACION_SESION);
ini_set("session.gc_maxlifetime",DURACION_SESION); 
ini_set("session.save_path","/tmp");
session_cache_expire(DURACION_SESION);
session_start();
session_regenerate_id(true); 
    
answered by 23.02.2018 в 05:05