Sha256: 6549465dfac7c168f5aef23f72d4427d8a2ff0731ff0ccdd4726633d4faf2239

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

/*!
 * Ext JS Connect
 * Copyright(c) 2010 Sencha Inc.
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var utils = require('./../../utils');

/**
 * Create a new `Session` with the given request and `id`.
 * When `Store#get()` is called `id` becomes the session
 * data itself, at which time `id`'s properties are
 * applied to the `Session` instance.
 *
 * Examples:
 *
 *     new Session(req, 'asdfsfd');
 *     new Session(req, { id: 'asdfsadfa', name: 'tj' });
 *
 * @param {IncomingRequest} req
 * @param {String|Object} id or data
 * @api private
 */

var Session = module.exports = function Session(req, id) {
    Object.defineProperty(this, 'req', { value: req });
    if (typeof id === 'object') {
        utils.merge(this, id);
    } else {
        this.touch();
    }
};

/**
 * Update lastAccess timestamp.
 *
 * @api public
 */

Session.prototype.touch = function(){
    this.lastAccess = +new Date;
};

/**
 * Destroy `this` session.
 *
 * @param {Function} fn
 * @api public
 */

Session.prototype.destroy = function(fn){
    delete this.req.session;
    this.req.sessionStore.destroy(this.req.sessionHash, fn);
};

/**
 * Regenerate this request's session.
 *
 * @param {Function} fn
 * @api public
 */

Session.prototype.regenerate = function(fn){
    this.req.sessionStore.regenerate(this.req, fn);
};

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vulcan-0.8.2 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.8.1 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.8.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.7.2 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.7.1 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.7.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.6.1 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.6.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.5.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.4.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.3.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.5 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.4 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.3 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.2 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.1 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.2.0 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.1.6 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.1.5 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js
vulcan-0.1.4 server/node_modules/connect-form/support/connect/lib/connect/middleware/session/session.js