Skip to content
Myr

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

4 files+56 added−0 removed

modified:docs/guide.1+13 added
1485 unmodified lines
1486.1487.IP "" 01488.1489.P1490The \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.nf14951496res\.cookie(\'rememberme\', \'yes\', { maxAge: 900000 });1497.1498.fi1499.1500.IP "" 01501.1502.P1503To parse incoming \fICookie\fR headers, use the \fIcookieDecoder\fR middleware, which provides the \fIreq\.cookies\fR object:1504.1505.IP "" 41506.
593 unmodified lines
modified:docs/guide.html+5 added
1186 unmodified lines
1187<pre><code>// "Remember me" for 15 minutes 1188res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });1189</code></pre>11901191<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>11921193<pre><code>res.cookie('rememberme', 'yes', { maxAge: 900000 });1194</code></pre>11951196<p>To parse incoming <em>Cookie</em> headers, use the <em>cookieDecoder</em> middleware, which provides the <em>req.cookies</em> object:</p>11971198<pre><code>app.use(express.cookieParser());1199
372 unmodified lines
modified:docs/migrate.1+26 added
132 unmodified lines
133.fi134.135.IP "" 0136.137.SS "res\.cookie()"138Previously only directly values could be passed, so for example:139.140.IP "" 4141.142.nf143144res\.cookie(\'rememberme\', \'yes\', { expires: new Date(Date\.now() + 900000), httpOnly: true });145.146.fi147.148.IP "" 0149.150.P151However 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.nf156157res\.cookie(\'rememberme\', \'yes\', { maxAge: 900000 });158.159.fi160.161.IP "" 0162.163.SS "res\.download() / res\.sendfile()"164Both 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 "" 4
63 unmodified lines
modified:docs/migrate.html+12 added
275 unmodified lines
276 req.accepts('png');277 // =&gt; false278</code></pre>279280<h3 id="res-cookie-">res.cookie()</h3>281282<p> Previously only directly values could be passed, so for example:</p>283284<pre><code>res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });285</code></pre>286287<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>288289<pre><code>res.cookie('rememberme', 'yes', { maxAge: 900000 });290</code></pre>291292<h3 id="res-download-res-sendfile-">res.download() / res.sendfile()</h3>293294<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