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);