ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 375 forks source link

Reconnect user on page refresh #106

Open vikasvyas946 opened 6 years ago

vikasvyas946 commented 6 years ago

Hi i want to ask one thing that if user refresh or reload page then it will automatically connect to websocket and continue to chat because currently if i refresh the page user will disconnect and connect with new connection.

ghedipunk commented 6 years ago

No, you can not reuse the same connection after it has been disconnected.

This is a security feature built into TCP/IP, rather than a limitations of this WebSockets library, the WebSockets protocol in general, etc.

Rather, if you want to resume the user's session across different connections, you will need a way to track that user, such as having them log in again, use a session cookie and read it during the handshake, etc.