Socket
Book a DemoInstallSign in
Socket

express-token-session

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-token-session

- [exports.Store](#exportsstore) - [warning](#warning) - [session()](#session) - [req.session](#reqsession) - [Session#destroy()](#sessiondestroy) - [Session#reload()](#sessionreload) - [Session#save()](#sessionsave) - [Session#touch()](#ses

1.2.1
latest
Source
npmnpm
Version published
Weekly downloads
2
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source
  • exports.Store
  • warning
  • session()
  • req.session
  • Session#destroy()
  • Session#reload()
  • Session#save()
  • Session#touch()

exports.Store

Expose constructors.

warning

Warning message for MemoryStore usage in production.

session()

Session:

Setup session store with the given `options`.

Examples:

  connect()
    .use(connect.json())
    .use(connect.session()

Options:

- `store` session store instance
 - `logger` optional logger provided by [log4js-node](https://github.com/nomiddlename/log4js-node)

req.session

To store or access session data, simply use the request property req.session, which is (generally) serialized as JSON by the store, so nested objects are typically fine. For example below is a user-specific view counter:

    connect()
      .use(connect.favicon())
      .use(connect.json())
      .use(connect.session()
      .use(function(req, res, next){
        var sess = req.session;
        if (sess.views) {
          res.setHeader('Content-Type', 'text/html');
          res.write('<p>views: ' + sess.views + '</p>');
          res.end();
          sess.views++;
        } else {
          sess.views = 1;
          res.end('welcome to the session demo. refresh!');
        }
      }
    )).listen(3000);

Session#destroy()

Destroys the session, removes req.session.

   req.session.destroy(function(err){
     // cannot access session here
   });

Session#reload()

Reloads the session data.

   req.session.reload(function(err){
     // session updated
   });

Session#save()

Save the session.

   req.session.save(function(err){
     // session saved
   });

Session#touch()

Updates the .maxAge property. Typically this is not necessary to call, as the session middleware does this for you.

Session Store Implementation:

Every session store must implement the following methods

  • .get(sid, callback)
  • .set(sid, session, callback)
  • .destroy(sid, callback)

Recommended methods include, but are not limited to:

  • .length(callback)
  • .clear(callback)

For an example implementation view the token-session-redis repo.

FAQs

Package last updated on 30 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.