Created
October 30, 2011 15:32
-
-
Save nanodeath/1326031 to your computer and use it in GitHub Desktop.
Sharing session store between http and non-http in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{MemoryStore} = require('connect').session | |
sessionStore = new MemoryStore | |
app.configure -> | |
app.use express.session({secret: "my_super_secret", store: sessionStore}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.configure -> | |
# ... | |
app.use express.session({secret: "my_super_secret"}) | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
everyone.now.playerJoined = () -> | |
sid = unescape(@user.cookie["connect.sid"]) # you DO have to unescape the session id! | |
sessionStore.get(sid, (err, sess) -> | |
console.log("That player who joined? his userId is #{sess.userId}") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment