How do you find the current Session Id on the client?
I am able to get what seems like the last session id, not the current session id.
console.log(Meteor.default_connection._lastSessionId)
The wording for this is a bit confusing, but _lastSessionId
is the current session id.
It is only called this because if the client is disconnected and seeks to reconnect it wants to re-establish the session with the last session id.
The client would reconnect with a message like this :
{"msg": "connect ", "session": "ERoZSR3R3f8zBQ6Ry", "version": "pre1","support":["pre1"]}
The session
uses the lastSessionId value. This is then used to re-establish the previous connection.
This is the only case where a new session id would be assigned on a reconnection. That or the session is expired off the server.
If the server restarts it's cache is refreshed and it wouldn't recognize the session anymore, and a new session id would be assigned.
The Meteor login token by default is stored in local storage (not in cookie).
On the client you could access
token = Meteor._localStorage.getItem('Meteor.loginToken')
On the server, once token is received, use the Accounts api to hash using
Accounts._hashLoginToken(res.req.body.token)
Then, you could validate hashed value against users collection for services.resume.loginTokens.hashedToken
field
This hack can be used to build meteor - express integration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With