Configuration for Sails built-in session store.
Sails session integration leans heavily on the great work already done by Express and Connect, but also adds
a bit of its own special sauce to unify Socket.io with the Connect session store. It uses Connect’s
cookie parser to normalize configuration differences between Express and Socket.io and hooks into Sails’
request interpreter to allow Sails to automatically access and auto-save changes your code makes to
when handling a virtual request from Socket.io. That means that you can just write code that uses
in the way you might be used to from Express or Connect.
||n/a||This session secret is automatically generated when your new app is created. Care should be taken any time this secret is changed in production-- doing so will invalidate the cookies of your users, forcing them to log in again.|
||Session key is set as
||If specified, the name of a Connect session adapter to use. More details below.|
Configuring Redis as Your Session Store
In production, uncomment the following line to set up a shared redis session store that can be shared across multiple Sails.js servers:
The following values are optional, if no options are set a redis instance running on
localhost is expected. Read more about these options at: https://github.com/visionmedia/connect-redis
host: 'localhost', port: 6379, ttl: <redis session TTL in seconds>, db: 0, pass: <redis auth password> prefix: 'sess:'
Using Other Connect-Compatible Session Stores
Any session adapter written for Connect/Express works in Sails, as long as you use a compatible version.
For example to use Mongo as your session store, you should use version 0.8.4 of
connect-mongo. First, run the following from your project's directory:
npm install [email protected] --save
Then add the following lines to your session configuration dictionary in
adapter: 'mongo', host: 'localhost', port: 27017, db: 'sails', collection: 'sessions',
The following values are optional, and should only be used if relevant for your Mongo configuration. You can read more about these, and other available options, at https://github.com/kcbanner/connect-mongo.
// Note: url will override other connection settings // url: 'mongodb://user:[email protected]:port/database/collection', username: '', password: '', auto_reconnect: false, ssl: false, stringify: true
Sessions are enabled by default in Sails. To disable sessions in your app, disable the
session hook. Note that tthe process for disabling any hook is identical to the process for disabling the Grunt hook (just type
grunt instead of