Session_id resume session content

Source: Internet
Author: User

Session_id () to access the current session code.

Syntax: String session_id (string [ID]);

This function can obtain or reconfigure the current session code. If no parameter ID is provided, only the current session code is obtained. If the parameter is added, the session code is set to the new specified ID. The input and return parameters are strings.

Output session_id ()

<? Phpsession_start (); echo session_id (); // output dqr58dnuqj2gufvg4o3tmjb9v4?> <? Phpsession_id ("nowamagic"); session_start (); echo session_id (); // output nowamagic?>
Session_id resume session content

PHP session can be recovered by the program, which is not the same as Java. The session recovery mechanism can be used to share sessions of multiple applications, because PHP sessions are stored in the form of files or databases. First, the session_id is obtained through the session_id () function. This value can be passed.

To resume a session, you must first know the session_id. You can use the manual to know that the session is restored by session_id ($ id). However, you must pay attention to the sequence when restoring the session, to obtain the content of the previous session, you must execute session_id ($ id) before session_start () so that the previous content can be restored when the session is initialized when session_start is executed, otherwise, you will get an empty session and you will not get anything. Previously, the session was reinitialized. This is closely related to the role of session_start (), because session_start tells PHP that the session should be initialized and deserialized from the session file, therefore, session_start is used to deserialize the previously stored file content. Before serialization, session_start needs to know the session_id. If no session_id is generated, a new one is generated. If yes, deserialize the content of the corresponding file.


Session_id resume session content

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.