Home  >  Q&A  >  body text

php - How to dynamically set the session to be deleted/retained when closing the browser in Laravel?

As far as I know, session uses cookies to store a session id to authenticate login. When the cookie of session id is set to be stored in memory, it will disappear when the browser is closed. If the expiration time is set, it will be saved to Local, it will be deleted when the time is up.

The official documentation of Laravel only states that the configuration file can control this.

How can I set the expiration time of the session id in the code instead of in the configuration file (how long should it be stored locally on the client or stored in memory, and will be automatically deleted when the browser is closed)?

thank you all

PHP中文网PHP中文网2697 days ago745

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-31 10:36:32

    https://github.com/laravel/la...

    There are two configurations here

    • lifetime = 120, control the expiration time, the default is 120 minutes

    • expire_on_close = false, when closing the browser, whether the session expires, the default is false, the default is not to expire, there is lifetime time, if expire_on_close = true is set, then the session will expire when the browser is closed

    In fact, the English of the configuration file already explains it very well

    reply
    0
  • Cancelreply