If the page is not operated for a long time, how to automatically exit the session? Tutorial: if the page is not operated for a long time, how to automatically exit the session. if the sessionphp page is not operated for a long time, how can I automatically exit the session?
Tutorial: if the page is not operated for a long time, how can I automatically exit the session.
Session php
Share:
------ Solution --------------------
Impossible, because php won't take the initiative to work
However, you can put the current time in the session as the basis for judging whether the time has timed out at the next entry.
------ Solution --------------------
There are only two scenarios for Session destruction: first, session is called. invalidate () method. second, the first and second requests exceed the lifecycle specified by the session. the default value is 30 minutes. if it exceeds 30 minutes, it is automatically cleared. This value can be set.
------ Solution --------------------
Reference:
Quote: reference:
There are only two scenarios for Session destruction: first, session is called. invalidate () method. second, the first and second requests exceed the lifecycle specified by the session. the default value is 30 minutes. if it exceeds 30 minutes, it is automatically cleared. This value can be set.
You can ask how to set the value of this period. Thank you
This is something that relies on js to work. For example, each page header has a js ID. As for how to implement it. Everyone has their own ideas, and then the timer ajax requests php, and then php can do everything they want ..
------ Solution --------------------
You can set the session lifecycle in php. ini.
More flexible options ――
Session files, databases, and cookies
The first two types can be used to delete session-related files or records based on time control through php, and the last one can control the cookie
But the trigger method? because there is no operation for a long time, it is difficult to trigger it by a third party.
Reference
The SessionHandler class
(PHP 5> = 5.4.0)
The SessionHandlerInterface class
(PHP 5> = 5.4.0)
------ Solution --------------------
Reference:
Quote: reference:
There are only two scenarios for Session destruction: first, session is called. invalidate () method. second, the first and second requests exceed the lifecycle specified by the session. the default value is 30 minutes. if it exceeds 30 minutes, it is automatically cleared. This value can be set.
You can ask how to set the value of this period. Thank you
Session. gc_maxlifetime in php. ini
------ Solution --------------------
Set the session length.
------ Solution --------------------
Reference:
You can set the session lifecycle in php. ini.
More flexible options ――
Session files, databases, and cookies
The first two types can be used to delete session-related files or records based on time control through php, and the last one can control the cookie
But the trigger method? because there is no operation for a long time, it is difficult to trigger it by a third party.
Reference
The SessionHandler class
(PHP 5> = 5.4.0)
The SessionHandlerInterface class
(PHP 5> = 5.4.0)
The last two references are the ultimate solutions. The service logic does not need to consider session expiration.