Can I access a cookie from Socket.io?

前端 未结 4 1803
孤街浪徒
孤街浪徒 2020-12-05 12:55

I want to set some user information in a cookie and be able to access it on connection, is this possible?

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 13:49

    Using Socket.IO 0.8.7, you can access request headers via:

    socket.handshake.headers

    You can find more detail on this at https://github.com/LearnBoost/socket.io/wiki/Authorizing

提交回复
热议问题