How to obtain the last session data of the browser)

Source: Internet
Author: User

How to obtain the last session data of the browser:

Do you want to know what session_id is for the last session?

Do you want the PHPSESSID value stored in the cookie to be deleted as soon as the browser exits?

Therefore, we need to set our own session_id instead of Automatically Generated

Therefore, we need to set the cookie-saved key = "value's lifecycle modification to become longer

<? PHP
Session_id (110 );
// Change the life cycle of the session ID stored in the cookie to 10 minutes.
// The PHPSESSID stored in the cookie will not be deleted once the browser exits.
Session_set_cookie_params (60*10 );
Session_start ();
Echo "session_id =". session_id (). "<br/> ";
$ _ Session ['name'] = "wuxifu001, hello, how do you do !!!! ";
Echo "Hello <br/> ";
?>


Set the same as above when obtaining the data.

<? PHP
Session_id (110 );
// Change the life cycle of the session ID stored in the cookie to 10 minutes.
// The PHPSESSID stored in the cookie will not be deleted once the browser exits.
Session_set_cookie_params (60*10 );
Session_start ();
Print_r ($ _ session );
Echo "<br/> ";
Print_r ($ _ cookie );


?>

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.