Recently, I am working on a websocket project. I don't understand many things for the first time, so I want to ask a question: If many client links come up, how can I verify the validity of this client? I read the handshake protocol and it seems that I can't do anything. Thank you for your guidance. Recently, I am working on a websocket project. I don't understand many things for the first time, so I want to ask a question: If many client links come up, how can I verify the validity of this client? I read the handshake protocol and it seems that I can't do anything. Thank you for your guidance.
Reply content:
Recently, I am working on a websocket project. I don't understand many things for the first time, so I want to ask a question: If many client links come up, how can I verify the validity of this client? I read the handshake protocol and it seems that I can't do anything. Thank you for your guidance.
I have never done it. it may be like this if I want to do it:
1. when creating a socket connection, you must send the cookie information of the current site once, for example, PHPSESSID.
2. if this user logs on, the web server will record the user's session (for example, in the database or cache), and the socket server will verify whether the session exists at the same place, or call the interface.
Send the user's sessionidto the server. the server reads session data from the disk or storage based on the sessionid to know whether the user is logged on.