Message from discussion
Express 3: Cookie maxAge to be set in Milliseconds or seconds ?
Received: by 10.58.169.70 with SMTP id ac6mr6584596vec.8.1352754275629;
Mon, 12 Nov 2012 13:04:35 -0800 (PST)
X-BeenThere: express-js@googlegroups.com
Received: by 10.220.155.207 with SMTP id t15ls8297815vcw.8.gmail; Mon, 12 Nov
2012 13:04:32 -0800 (PST)
Received: by 10.52.96.71 with SMTP id dq7mr4044194vdb.11.1352754272742;
Mon, 12 Nov 2012 13:04:32 -0800 (PST)
Date: Mon, 12 Nov 2012 13:04:32 -0800 (PST)
From: Alfredo FP <chinova...@gmail.com>
To: express-js@googlegroups.com
Message-Id: <e398c3a4-429c-422e-95d1-e8f4ba593d40@googlegroups.com>
In-Reply-To: <db8317ed-d70f-4966-bcdc-5f9d77dbd471@px4g2000pbc.googlegroups.com>
References: <682d0b78-e557-4881-8677-ea0fee32bef6@googlegroups.com>
<db8317ed-d70f-4966-bcdc-5f9d77dbd471@px4g2000pbc.googlegroups.com>
Subject: Re: Express 3: Cookie maxAge to be set in Milliseconds or seconds ?
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_333_28285906.1352754272310"
------=_Part_333_28285906.1352754272310
Content-Type: multipart/alternative;
boundary="----=_Part_334_2045018.1352754272310"
------=_Part_334_2045018.1352754272310
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Thanks for your reply!
However, I still see a problem here.
I have checked the source code of express (3.0.2), and it looks there is a
bug (or the
documentation is not correct)
The line in function cookie (response.js):
* if ('maxAge' in options) options.expires = new Date(Date.now() +
options.maxAge);*
does not modify the value in *options.maxAge*,
Then, in function serialize of the cookie module:
* if (opt.maxAge) pairs.push('Max-Age=' + opt.maxAge);*
Actually, this is correct, because browsers expect the delta in Max-Age to
be seconds (http://www.w3.org/Protocols/rfc2109/rfc2109)
To be consistent, the documentation should be corrected, or the source code
fixed.
*
*
* if ('maxAge' in options) { options.expires = new Date(Date.now() +
options.maxAge); options.maxAge /= 1000; }**
*
*
*
I hope this helps.
------=_Part_334_2045018.1352754272310
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<div>Thanks for your reply!</div><div><br></div><div>However, I still see a=
problem here.</div><div><br></div>I have checked the source code of expres=
s (3.0.2), and it looks there is a bug (or the<div>documentation is not cor=
rect)</div><div><br></div><div>The line in function cookie (response.js):</=
div><div><br></div><div><div> <i> if ('maxAge' in options) <b>options.=
expires</b> =3D new Date(Date.now() + <b>options.maxAge</b>);</i></div><div=
><br></div></div><div>does not modify the value in <b>options.maxAge</b>,</=
div><div><br></div><div>Then, in function serialize of the cookie module:</=
div><div><br></div><div><i> if (<b>opt.maxAge</b>) pairs.push('Max-Age=
=3D' + <b>opt.maxAge</b>);</i><br></div><div><br></div><div>Actually, this =
is correct, because browsers expect the delta in Max-Age to be seconds =
;(http://www.w3.org/Protocols/rfc2109/rfc2109)</div><div><br></div><div>To =
be consistent, the documentation should be corrected, or the source co=
de fixed.</div><div><b><br></b></div><div><i> if ('maxAge' in options)=
{ <b>options.expires</b> =3D new Date(Date.now() + <b>optio=
ns.maxAge</b>); <b>options.maxAge /=3D 1000</b>; }</i><b><br></b></div><div=
><i><br></i></div><div>I hope this helps.</div><div><br></div><div><br></di=
v><div><br></div>
------=_Part_334_2045018.1352754272310--
------=_Part_333_28285906.1352754272310--