How to have PHP session expire upon browser close OR some extended duration of time

£可爱£侵袭症+ 提交于 2019-12-06 03:54:28

The solution might be to set data via ini_set('session.gc_maxlifetime', <lifetime in seconds>); Of course if it's possible to change config via PHP. Otherwise you wil need to set proper values in your php.ini:

ini_set(‘session.gc_maxlifetime’,30);
ini_set(‘session.gc_probability’,1);
ini_set(‘session.gc_divisor’,1);

The other approach is setting validity of session cookie by:

$expire=24*60*60;
session_set_cookie_params($expire);
session_start();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!