Tools, FAQ, Tutorials:
Testing the Session Garbage Collection Process in PHP
How To Test the Session Garbage Collection Process in PHP?
✍: FYIcenter.com
In order to test the session garbage collection process, you need to change the settings to expire session variables in 10 seconds and run the process on every request:
session.gc_probability = 1 session.gc_divisor = 1 session.gc_maxlifetime = 10
If you re-run the first_page.php and next_page.php scripts presented in the previous tutorials, you will see some thing like:
Query string of the incoming URL: Cookies received: PHPSESSID = grm557vicj1edmiikgsa8hbd11 Value of MyLogin has been retrieved: FYICenter Value of MyColor has been retrieved: Blue
Wait for 10 seconds, and start another browser window to run first_page.php. This is to trigger the session garbage collection process to remove values stored in session grm557vicj1edmiikgsa8hbd11.
Go back to the first browser window on second_page.php, and click the browser refresh button, you will get something like:
Query string of the incoming URL: Cookies received: PHPSESSID = grm557vicj1edmiikgsa8hbd11 Value of MyLogin has been retrieved: Value of MyColor has been retrieved:
As you can see, session values are gone, the browser is still sending the same session ID as a cookie, but the all session values are expired (actually, the session file is removed by the garbage collection process).
⇒ Setting session.gc_maxlifetime Properly in PHP
⇐ Timeout Period on Session Values in PHP
2016-10-24, 1749🔥, 0💬
Popular Posts:
What is the Azure AD v1.0 OpenID Metadata Document? Azure AD v1.0 OpenID Metadata Document is an onl...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...