PHP session lifetime problem

后端 未结 4 400
灰色年华
灰色年华 2020-12-12 03:09

I\'m using PHP5 here. I have made a login system that check\'s the username and password against the records in the database. I want to use sessions to store the logged valu

4条回答
  •  孤街浪徒
    2020-12-12 03:47

    You can change the configuration setting session.cookie_lifetime, e.g. in php.ini or a .htaccess file:

    session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.

    This means (I think) that you can't have both expiry based on a timeout and expiry when the browser is closed. So maybe the best bet is to keep the default and set your own timer in $_SESSION as others have suggested, thus rendering this answer pointless.

提交回复
热议问题