from past two days i am facing this problem. whenever i restart my sails server session got expired and all users got logged out. Is there any way to overcome from this ? I have gone through the sails doc but not successful to save the session in database.
Asked
Active
Viewed 152 times
0
-
You need to provide more details about your problem if you really hope to get any help. – JoeG Feb 12 '16 at 13:46
-
adapter: 'mongo', host: 'localhost', port: 27017, db: 'sails', collection: 'sessions', – Ankur Feb 12 '16 at 14:28
2 Answers
0
EDIT: There seems to be a bug in sails
that's preventing mongo session store from working as expected.
EDIT2: The documentation repository has been updated and the website should be updated soon as well.
You need to use mongo-connect v0.8.2 if you're using node <=0.12.x, and mongo-connect >= v1.0.0 if you're using node >= v4.x
You will have to update your sessions configuration
To use mongo as a session store, install the connect-mongo
package as a dependency
npm install connect-mongo
Then in config/sessions.js
module.exports.sessions = {
adapter: 'mongo',
host: 'localhost',
port: 27017,
db: 'sails',
collection: 'sessions',
};

elssar
- 5,651
- 7
- 46
- 71
-
I have gone through the sails doc but not successful to save the session in database. @elssar and need to tell u this they have mentioned wrong version of connect mongo – Ankur Feb 13 '16 at 09:24
-
Thats odd, probably a typo in the docs. There is a version 0.8.2 available, does that work? – elssar Feb 14 '16 at 01:42
-
Looks like there is a bug in sails that's preventing mongo sessions from working - https://github.com/balderdashy/sails/issues/3574 – elssar Feb 15 '16 at 02:58
0
You can store session in redis. After restarting session is not cleared.
sails 0.11.2
redis-connect 1.4.7
In session.js
adapter: 'connect-redis'

Bonanza
- 1,601
- 14
- 23