Home  >  Q&A  >  body text

html5 - websocket如何带上cookie?

websocket如何带上cookie?

天蓬老师天蓬老师2743 days ago1135

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 13:05:00

    HTTP is a stateless connection and only needs cookies to record the status
    And websocket always maintains a connection, so there is no need for cookies. When you need to share the login information of the previous system, just send the cookie directly.
    What you need should be an authentication mechanism. This mechanism can be compatible with the cookie implementation just mentioned,
    or use Basic Auth, OAuth 2 or the like

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:05:00

    websocket is a link to the TCP/IP layer, and cookies are things of the application layer HTTP protocol, so they cannot.
    Unless websocket the downgrade solution is used when the browser does not support it.

    reply
    0
  • Cancelreply