Skip to content

lennym/express-secure-cookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-secure-cookie

An opinionated replacement for express' res.cookie method.

Automatically detects whether to set secure flag dependent on request protocol. Defaults httpOnly to true.

Install

npm install express-secure-cookie

Usage

var app = require('express')();

app.use(require('express-secure-cookie'));

app.get('*', function (req, res) {
    res.cookie('foo', 'bar');
    // this cookie will now have its `secure` flag set appropriately for
    // the protocol of the inbound request - i.e. http/s
    // the cookie will also have its `httpOnly` flag set to true meaning
    // it cannot be read by `document.cookies`
});

...

app.listen(8080);

About

Automatically detect whether to set secure flag in express `res.cookie` dependent on request protocol

Resources

License

Stars

Watchers

Forks

Packages

No packages published