N
N
Nwton2016-06-13 00:07:13
Node.js
Nwton, 2016-06-13 00:07:13

How to get io cookie?

When making a client-server connection, socket.io creates a cookie in the browser called io. If you look at the details of the cookie, then the parameter path is "/socket.io"
How to get this cookie in the application when requesting the main page "/".
I get other cookies like this:

app.get('/', function(req, res){
  cookies = cookieParser.JSONCookies(req.cookies);
  ...

When trying to get cookies.io gives undefined

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#algooptimize #bottize, 2016-06-13
@Nwton

If the cookie has a path, then the client will not return a cookie that has a path that does not include the specified path.

A
Artem Kayun, 2016-06-13
@Kayun

You need to pass cookies from http to ws. The example uses redis, but you can do without it.
stackoverflow.com/questions/4753957/socket-io-auth...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question