Skip to content

Commit

Permalink
docs for res.cookie()
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Mar 3, 2011
1 parent 4c274c5 commit 00e1dbf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -3,6 +3,7 @@
==================

* Added HTTPS support
* Added `res.cookie()` maxAge support
* Added `req.header()` _Referrer_ / _Referer_ special-case, either works
* Added mount support for `res.redirect()`, now respects the mount-point
* Added `union()` util, taking place of `merge(clone())` combo
Expand Down
4 changes: 4 additions & 0 deletions docs/guide.md
Expand Up @@ -847,6 +847,10 @@ Sets the given cookie _name_ to _val_, with options _httpOnly_, _secure_, _expir
// "Remember me" for 15 minutes
res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });

The _maxAge_ property may be used to set _expires_ relative to _Date.now()_ in milliseconds, so our example above can now become:

res.cookie('rememberme', 'yes', { maxAge: 900000 });

To parse incoming _Cookie_ headers, use the _cookieDecoder_ middleware, which provides the _req.cookies_ object:

app.use(express.cookieParser());
Expand Down
10 changes: 10 additions & 0 deletions docs/migrate.md
Expand Up @@ -75,6 +75,16 @@
req.accepts('png');
// => false

### res.cookie()

Previously only directly values could be passed, so for example:

res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });

However now we have the alternative _maxAge_ property which may be used to set _expires_ relative to _Date.now()_ in milliseconds, so our example above can now become:

res.cookie('rememberme', 'yes', { maxAge: 900000 });

### res.download() / res.sendfile()

Both of these methods now utilize Connect's static file server behind the scenes (actually the previous Express code was ported to Connect 1.0). With this change comes a change to the callback as well. Previously the _path_ and _stream_ were passed, however now only an _error_ is passed, when no error has occurred the callback will be invoked indicating that the file transfer is complete. The callback remains optional:
Expand Down

0 comments on commit 00e1dbf

Please sign in to comment.