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

getCookie returned more than just session id; had to trim to make it work #19

Closed
TimeBomb opened this issue Apr 9, 2013 · 1 comment
Labels

Comments

@TimeBomb
Copy link

TimeBomb commented Apr 9, 2013

I was having issues getting session.socket.io to work, though after a bit of debugging, I've finally traced and put a bandaid on the issue - though my patch is a bit dirty, and I'm unsure if I've missed something that may be the origin of this issue.

So getCookie was returning something along the following (from handshake.cookies):
s:[sessionId].[trailingCharacters]
Wherein [sessionId] was the valid session id.

The sessionStore.load method is looking only for the session id, and thus it failed to get the session because of this issue. By using simple string manipulation, I was able to get the actual session id out of the cookie value, thus making the entire module work.

So I changed this line:
sessionStore.load(findCookie(socket.handshake), function (storeErr, session) {

to this:
sessionStore.load(findCookie(socket.handshake).substring(2).split('.')[0], function (storeErr, session) {

Here's a gist of test code that I've used to reproduce this issue: https://gist.github.com/TimeBomb/d992c84401d6e02b1c77

It errors out without the change I've made. With the change I've made, upon loading for the second time, it shows that the session test var is 1, as expected.

FYI, I'm using the latest version (as of 04/08/2013) of all the modules required in the aforementioned test code.

@wcamarao
Copy link
Owner

Can you try passing your secretToken to your call to cookieParser() as highlighted on your gist below?

https://gist.github.com/TimeBomb/d992c84401d6e02b1c77#file-gistfile1-js-L6

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

No branches or pull requests

2 participants