dox-foundation-demo node_modules/express/node_modules/connect/lib/middleware/session/session.js

utils

declaration
utils

    Description

    Module dependencies.

    Source

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

    touch

    method
    Session.prototype.touch()
    • @return: {Session}for chaining

    Description

    Update reset .cookie.maxAge to prevent
    the cookie from expiring when the
    session is still active.

    Source

    Session.prototype.touch = function(){
      return this.resetMaxAge();
    };

    resetMaxAge

    method
    Session.prototype.resetMaxAge()
    • @return: {Session}for chaining

    Description

    Reset .maxAge to .originalMaxAge.

    Source

    Session.prototype.resetMaxAge = function(){
      this.cookie.maxAge = this.cookie.originalMaxAge;
      return this;
    };

    save

    method
    Session.prototype.save()
    • @param: {Function}fn
    • @return: {Session}for chaining

    Description

    Save the session data with optional callback fn(err).

    Source

    Session.prototype.save = function(fn){
      this.req.sessionStore.set(this.id, this, fn || function(){});
      return this;
    };

    reload

    method
    Session.prototype.reload()
    • @param: {Function}fn
    • @return: {Session}for chaining

    Description

    Re-loads the session data without altering
    the maxAge properties. Invokes the callback fn(err),
    after which time if no exception has occurred the
    req.session property will be a new Session object,
    although representing the same session.

    Source

    Session.prototype.reload = function(fn){
      var req = this.req
        , store = this.req.sessionStore;
      store.get(this.id, function(err, sess){
        if (err) return fn(err);
        if (!sess) return fn(new Error('failed to load session'));
        store.createSession(req, sess);
        fn();
      });
      return this;
    };

    destroy

    method
    Session.prototype.destroy()
    • @param: {Function}fn
    • @return: {Session}for chaining

    Description

    Destroy this session.

    Source

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

    regenerate

    method
    Session.prototype.regenerate()
    • @param: {Function}fn
    • @return: {Session}for chaining

    Description

    Regenerate this request's session.

    Source

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