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 00e1dbf · Browse files · 4 files·+56 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
4 files+56 added−0 removed
- other:+56 added−0 removed
Provenance
- Commit
131970b- Tree
213c8b4- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
00e1dbf
4 files changed+56 added−0 removed
modified:docs/guide.1+13 added
1485 unmodified lines1486 .1487 .IP "" 01488 .1489 .P1490+The \fImaxAge\fR property may be used to set \fIexpires\fR relative to \fIDate\.now()\fR in milliseconds, so our example above can now become:1491+.1492+.IP "" 41493+.1494+.nf1495+1496+res\.cookie(\'rememberme\', \'yes\', { maxAge: 900000 });1497+.1498+.fi1499+.1500+.IP "" 01501+.1502+.P1503 To parse incoming \fICookie\fR headers, use the \fIcookieDecoder\fR middleware, which provides the \fIreq\.cookies\fR object:1504 .1505 .IP "" 41506 .593 unmodified linesmodified:docs/guide.html+5 added
1186 unmodified lines1187 <pre><code>// "Remember me" for 15 minutes 1188 res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });1189 </code></pre>1190 1191+<p>The <em>maxAge</em> property may be used to set <em>expires</em> relative to <em>Date.now()</em> in milliseconds, so our example above can now become:</p>1192+1193+<pre><code>res.cookie('rememberme', 'yes', { maxAge: 900000 });1194+</code></pre>1195+1196 <p>To parse incoming <em>Cookie</em> headers, use the <em>cookieDecoder</em> middleware, which provides the <em>req.cookies</em> object:</p>1197 1198 <pre><code>app.use(express.cookieParser());1199 372 unmodified linesmodified:docs/migrate.1+26 added
132 unmodified lines133 .fi134 .135 .IP "" 0136 .137+.SS "res\.cookie()"138+Previously only directly values could be passed, so for example:139+.140+.IP "" 4141+.142+.nf143+144+res\.cookie(\'rememberme\', \'yes\', { expires: new Date(Date\.now() + 900000), httpOnly: true });145+.146+.fi147+.148+.IP "" 0149+.150+.P151+However now we have the alternative \fImaxAge\fR property which may be used to set \fIexpires\fR relative to \fIDate\.now()\fR in milliseconds, so our example above can now become:152+.153+.IP "" 4154+.155+.nf156+157+res\.cookie(\'rememberme\', \'yes\', { maxAge: 900000 });158+.159+.fi160+.161+.IP "" 0162+.163 .SS "res\.download() / res\.sendfile()"164 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 \fIpath\fR and \fIstream\fR were passed, however now only an \fIerror\fR is passed, when no error has occurred the callback will be invoked indicating that the file transfer is complete\. The callback remains optional:165 .166 .IP "" 463 unmodified linesmodified:docs/migrate.html+12 added
275 unmodified lines276 req.accepts('png');277 // => false278 </code></pre>279 280+<h3 id="res-cookie-">res.cookie()</h3>281+282+<p> Previously only directly values could be passed, so for example:</p>283+284+<pre><code>res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });285+</code></pre>286+287+<p>However now we have the alternative <em>maxAge</em> property which may be used to set <em>expires</em> relative to <em>Date.now()</em> in milliseconds, so our example above can now become:</p>288+289+<pre><code>res.cookie('rememberme', 'yes', { maxAge: 900000 });290+</code></pre>291+292 <h3 id="res-download-res-sendfile-">res.download() / res.sendfile()</h3>293 294 <p> 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 <em>path</em> and <em>stream</em> were passed, however now only an <em>error</em> is passed, when no error has occurred the callback will be invoked indicating that the file transfer is complete. The callback remains optional:</p>295 42 unmodified lines