Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-session

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-session - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

lib/index.js

13

package.json
{
"name": "next-session",
"version": "0.0.1",
"version": "0.0.2",
"description": "Simple session middleware for Next.js API Routes",
"main": "index.js",
"main": "lib/index.js",
"files": [
"lib/"
],
"scripts": {
"lint": "eslint ./ -c .eslintrc --ext js --ignore-path .gitignore --fix",
"build": "babel src -d lib",
"lint": "eslint src -c .eslintrc --ext js --ignore-path .gitignore --fix",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -21,2 +25,5 @@ },

"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"eslint": "^5.16.0",

@@ -23,0 +30,0 @@ "eslint-config-airbnb-base": "^13.2.0",

@@ -14,6 +14,23 @@ # next-session

```javascript
// Using Node.js require
const session = require('next-session');
// Using ES6 import
import session from 'next-session';
const handler = (req, res) => {
if (req.session.views) {
// On later visits, increase # of views by one on every request
req.session.views += 1;
} else {
// On first visit, set # of views to 1
req.session.views = 1;
}
res.send(`In this session, you have visited this page ${req.session.views} time(s).`)
};
// wrap handler with session middleware and include options
export default session(handler, {
name: 'sid',
cookies: {
secure: true,
maxAge: 1209600000,
},
});
```

@@ -20,0 +37,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc