Home >Backend Development >PHP Tutorial >The growth cycle of eyebrows Introduction to PHP5 Session life cycle
It is judged by the Session ID. What is the Session ID is the file name of the Session file. The Session ID is randomly generated, so it can ensure uniqueness and randomness and ensure the security of the Session. Generally, if the Session life cycle is not set, the Session ID is stored in the memory. After closing the browser, the ID is automatically logged out. After re-requesting the page, a new Session ID is registered.
If the client does not disable cookies, the cookie plays the role of storing the Session ID and Session lifetime when starting the Session session. Let's manually set the lifetime of the Session:
session_start(); // Save for one day $lifeTime = 24 * 3600; setcookie(session_name(), session_id(), time() + $lifeTime, "/"); ?> |
In fact, PHP5 Session also provides a function session_set_cookie_params(); to set the lifetime of PHP5 Session. This function must be called before the session_start() function is called. :
// Save for one day $lifeTime = 24 * 3600; session_set_cookie_params($lifeTime); session_start(); ?> |
The above introduces the growth cycle of eyebrows. An introduction to the life cycle of PHP5 Session, including the content of the growth cycle of eyebrows, I hope it will be helpful to friends who are interested in PHP tutorials.