Answer the question
In order to leave comments, you need to log in
How to identify a user in sockets?
Let's say I have a chat on sockets. I want to make it so that only those who have logged in to the site (if there is a value in $_SESSION['login']) can write to the chat. How to identify a user in sockets?
Answer the question
In order to leave comments, you need to log in
If there is a server on the same domain, then the same cookies will be sent to the server as in a normal request.
If the server is different, then when connecting to the WS server, we first send an authorization token (let it be PHPSESSID), then we work as an authorized user.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question