How PHP returns SessionID and how to get the relevant session via SessionID

Source: Internet
Author: User
How PHP returns SessionID and how to get data through SessionID

Reply content:

How PHP returns SessionID and how to get data through SessionID

The basic knowledge of the session
The session is stored on the server side, such as in a file, in Redis.
Now there are a lot of client Request server, the service side also generated a lot of sessions, then the client each request is how to find his session?
When each client requests a server, when the server generates a session, it assigns a unique ID to the session, which is used to mark the session, and the file name is the ID when it is saved to Redis, which is the ID of the Redis key.
It then returns the ID to the client and tells the client to save it to the cookie.

header 响应set-cookie:sessionid=123456

The next client access will bring this cookie, the server to get the ID in the cookie, to find the session. Read inside to save to data.

PHP gets the SessionID method for
session_id ();
You can get the contents of the specified SessionID
session_id (123456);

  • 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.