Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why you don't use cookie stored socket ID? #422

Closed
dlimkin opened this issue Sep 24, 2016 · 1 comment
Closed

Why you don't use cookie stored socket ID? #422

dlimkin opened this issue Sep 24, 2016 · 1 comment

Comments

@dlimkin
Copy link

dlimkin commented Sep 24, 2016

Hi,
I use a socket.id as ID of the session.
And I need to after refresh the page, socket is created based on the already generated ID (stored in client cookie).
In your code you are saving ID, but do not use it for a new connection.
Why not use something similar? (possibly optional)

Server.prototype.generateId = function(req){
  var c = parseCookie(req.headers.cookie);
  if(this.cookie && c[this.cookie]){
    return c[this.cookie];
  }
  return base64id.generateId();
};

Or maybe something like this already implemented and configured?

@darrachequesne
Copy link
Member

You're right, the default behaviour is to generate a new id on reconnection. You can provide your own generateId method though:

var engine = require('engine.io');
engine.generateId = <your custom function>

Please see the sample test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants