Skip to content
Myr

Cookie docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent a13df5b · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • other:+21 added−0 removed

1 file+21 added−0 removed

modified:docs/guide.md+21 added
498 unmodified lines
499Express supports "redirect mapping", which by default provides _home_, and _back_.500The _back_ map checks the _Referrer_ and _Referer_ headers, while _home_ utilizes501the "home" setting and defaults to "/".502503### res.cookie(name, val[, options])504505Sets the given cookie _name_ to _val_, with _options_ such as "httpOnly: true", "expires", "secure" etc.506507 // "Remember me" for 15 minutes 508 res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });509510To parse incoming _Cookie_ headers, use the _cookieDecoder_ middleware, which provides the _req.cookies_ object:511512 app.use(express.cookieDecoder());513 514 app.get('/', function(req, res){515 // use req.cookies.rememberme516 });517518### res.clearCookie(name)519520Clear cookie _name_ by setting "expires" far in the past.521522 res.clearCookie('rememberme');523524### res.render(view[, options[, fn]])525526Render _view_ with the given _options_ and optional callback _fn_.527When a callback function is given a response will _not_ be made
214 unmodified lines