03-sessions.js 604 Bytes

// # sessions 
var session = require('express-session');
var cookieParser = require('cookie-parser');

exports = module.exports = function (settings, sessions) {

    var app = this;
    // pass a secret to cookieParser() for signed cookies
    app.all(settings.notApiRouteRegexp, cookieParser(settings.cookieParser));

    // add req.session cookie support
    settings.session.store = sessions;
    app.all(settings.notApiRouteRegexp, session(settings.session));

    // add flash message support
    app.use(session(settings.session));
};

exports['@require'] = ['igloo/settings', 'igloo/sessions'];