Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 4, 2024 via pnpm

cookie-session 2.0.0

cookie session middleware
Package summary
Share
0
issues
1
license
9
MIT
Package created
23 Feb 2014
Version published
16 Dec 2021
Maintainers
5
Total deps
9
Direct deps
4
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
9 Packages, Including:
cookie-session@2.0.0
cookies@0.8.0
debug@3.2.7
depd@2.0.0
keygrip@1.1.0
ms@2.1.3
on-headers@1.0.2
safe-buffer@5.2.1
tsscmp@1.0.6
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

4
All Dependencies CSV
β“˜ This is a list of cookie-session 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
cookies0.8.07.11 kBMIT
prod
debug3.2.716.48 kBMIT
prod
on-headers1.0.23.15 kBMIT
prod
safe-buffer5.2.19.74 kBMIT
prod

Visualizations

Frequently Asked Questions

What does cookie-session do?

Cookie-Session is a simple, yet efficient Node.js module that facilitates the creation of cookies for session handling in web applications. It is primarily used as session middleware that stores session data on the client-side within a cookie. This approach is in contrast to traditional session handling methods where only a session identifier is stored within the cookie and the actual session data is stored server-side, typically in a database. With Cookie-Session, there is no need for server-side database resources for session handling, thus making it an ideal solution for lightweight applications, and for simplifying load-balanced scenarios.

How do you use cookie-session?

To use Cookie-Session, you first need to install it via the Node Package Manager (npm) by running "npm install cookie-session" in your terminal. Once installed, you can require it in your application and use it as middleware with Express. Set your options such as the cookie name, and secret keys, and cookie options like maxAge. Here's a basic example of how to use it:

var cookieSession = require('cookie-session')
var express = require('express')

var app = express()

app.use(cookieSession({
  name: 'session',
  keys: ['secret_key1', 'secret_key2'],

  // Cookie Options
  maxAge: 24 * 60 * 60 * 1000 // 24 hours
}))

app.get('/', function (req, res, next) {
  // Update views
  req.session.views = (req.session.views || 0) + 1

  // Write response
  res.end(req.session.views + ' views')
})

app.listen(3000)

In the above example, a session cookie gets created whenever a client makes a request to the root route ('/') the server. The session cookie stores the number of views for the user and this number keeps increasing with every request.

Where are the cookie-session docs?

The comprehensive documentation of the Cookie-Session npm package can be found on the official GitHub page - https://github.com/expressjs/cookie-session. It includes an API reference guide, options explanations, and several useful examples of usage scenarios. Detailed information about the methods, properties, and usage limitations of the package are readily available for developers to refer to.