Ask: If the page does not operate for a long time, how to let the session automatically exit.
Reply to discussion (solution)
Impossible, because PHP will not actively work
But you can put the current time in the session as the next entry to determine whether to timeout the basis
The session is destroyed in only two cases: first: The session invokes the Session.invalidate () method. Second: The previous two requests exceeded the lifecycle time specified by the session. Default 30 minutes, if more than 30 minutes are automatically emptied. This value can be set.
The session is destroyed in only two cases: first: The session invokes the Session.invalidate () method. Second: The previous two requests exceeded the lifecycle time specified by the session. Default 30 minutes, if more than 30 minutes are automatically emptied. This value can be set.
Can ask again, how to set the value of this period. Thanks
The session is destroyed in only two cases: first: The session invokes the Session.invalidate () method. Second: The previous two requests exceeded the lifecycle time specified by the session. Default 30 minutes, if more than 30 minutes are automatically emptied. This value can be set.
Can ask again, how to set the value of this period. Thanks
This thing will depend on JS to work. For example, each page header is put a JS logo. As to how to achieve. Everyone has their own ideas, then timer Ajax to request PHP, and then PHP would like to do all the ha.
Setting the session life cycle can be set in php.ini
More flexible way to do??
Session general file, database, cookie several ways
The first two can be based on the time control of PHP Delete session related files or records, the latter can control the cookie
But the trigger way, because it is a long time no operation, so self-triggering is difficult, to third-party trigger
Reference
The Sessionhandler class
(PHP 5 >= 5.4.0)
The Sessionhandlerinterface class
(PHP 5 >= 5.4.0)
The session is destroyed in only two cases: first: The session invokes the Session.invalidate () method. Second: The previous two requests exceeded the lifecycle time specified by the session. Default 30 minutes, if more than 30 minutes are automatically emptied. This value can be set.
Can ask again, how to set the value of this period. Thanks
The Session.gc_maxlifetime in php.ini.
Sets the length of time for the session.
Setting the session life cycle can be set in php.ini
More flexible way to do??
Session general file, database, cookie several ways
The first two can be based on the time control of PHP Delete session related files or records, the latter can control the cookie
But the trigger way, because it is a long time no operation, so self-triggering is difficult, to third-party trigger
Reference
The Sessionhandler class
(PHP 5 >= 5.4.0)
The Sessionhandlerinterface class
(PHP 5 >= 5.4.0)
The last two references are the ultimate solution. and can block the session expiration processing details, the business logic does not need to consider the session expiration situation.