D
D
dexforint2018-07-25 23:37:43
PHP
dexforint, 2018-07-25 23:37:43

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

1 answer(s)
N
Night, 2018-07-25
@maxtm

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 question

Ask a Question

731 491 924 answers to any question