How to set lifetime of session

后端 未结 6 2144
梦如初夏
梦如初夏 2020-11-27 03:36

How to set session lifetime in PHP? I Want to set it to forever as long as the request is exist. The request is AJAX. My PHP code that handle AJAX request is:



        
6条回答
  •  情书的邮戳
    2020-11-27 03:52

    Set following php parameters to same value in seconds:

    session.cookie_lifetime
    session.gc_maxlifetime
    

    in php.ini, .htaccess or for example with

    ini_set('session.cookie_lifetime', 86400);
    ini_set('session.gc_maxlifetime', 86400);
    

    for a day.

    Links:

    http://www.php.net/manual/en/session.configuration.php

    http://www.php.net/manual/en/function.ini-set.php

提交回复
热议问题