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

Write to session store -- and persist it? #7

Closed
aroman opened this issue Dec 3, 2012 · 2 comments
Closed

Write to session store -- and persist it? #7

aroman opened this issue Dec 3, 2012 · 2 comments
Labels

Comments

@aroman
Copy link

aroman commented Dec 3, 2012

Hey,

Great little library you've got here.

I use it in conjunction with a MongoStore, which also powers my Express HTTP sessions. Only thing is, when I (from inside a socket.io callback) modify the session exposed by this library, it only seems to persist in memory; when I restart the server, the changes are not reflected (and thus weren't saved in MongoDB).

Am I wrong in expecting the changes to be perserved in MongoDB? Or is the session only exposed as read-only through socket.io.

@wcamarao
Copy link
Owner

wcamarao commented Dec 3, 2012

Hey Avi, thanks for the feedback.

I'm not sure how to answer this directly but I will give you some information to go through and find the answer. When you do session.someValue = 1, it may look like it's not persisting anything as it's just changing an attribute in memory.

However someValue could be a setter (see links below) that also trigger a callback that persist into MongoDB. If not implemented yet, you could use this or a similar approach to keep your db synced.

Before implementing I'd also suggest asking this on MongoStore repo as they might have a configuration that do this job already.

http://ejohn.org/blog/javascript-getters-and-setters
https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8

@wcamarao
Copy link
Owner

hey @aroman have you solved this? if not take a look at issue 8 - it might help.

@wcamarao wcamarao closed this as completed Jan 2, 2013
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