About PHP5 Session life cycle Introduction _php Tutorial

Source: Internet
Author: User
It is determined by the session ID, what is the session ID, is the file name of the session file, session ID is randomly generated, so to ensure uniqueness and randomness, to ensure that the session security. In general, if the lifetime of the session is not set, the session ID is stored in memory, the ID is automatically logged off after the browser is closed, and a session ID is re-registered after the page is re-requested.

If the client does not disable cookies, the cookie plays the role of storing the session ID and session lifetime when the session is started. Let's set the lifetime of the Session manually:

Session_Start ();
Save the 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 the PHP5 session, the function must be called before the session_start () function call:

Save the day
$lifeTime = 24 * 3600;
Session_set_cookie_params ($lifeTime);
Session_Start ();
?>

http://www.bkjia.com/PHPjc/321407.html www.bkjia.com true http://www.bkjia.com/PHPjc/321407.html techarticle It is determined by the session ID, what is the session ID, is the file name of the session file, session ID is randomly generated, so can guarantee uniqueness and randomness, to ensure that ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.