#794: Session cookie should use "Max-Age" instead of "Expires"
----------------------------+-----------------------------------------------
Reporter:
ci...@online.de | Owner: rdelon
Type: defect | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords: session timeout expires max-age
----------------------------+-----------------------------------------------
In [source:branches/cherrypy-2.x/cherrypy/filters/sessionfilter.py
sessionfilter.py] (CherryPy 2.x) resp.
[source:trunk/cherrypy/lib/sessions.py sessions.py] (CherryPy 3.x), the
expiration time for the session cookie is set using the "Expires"
attribute (as an absolute timestamp), instead of the "Max-age" attribute
(a time delta).
A comment in the CherryPy code states that this is done to have the cookie
saved to disk if people close the browser, and it is considered as a
workaround for an alleged bug in MSIE. TurboGears copied this idea for its
own "visit" package, but it turned out that it has several drawbacks:
* Using the "Expires" attribute turns the cookie into a permanent cookie
that is treated differently in the browser (particularly MSIE), depending
on the security level it is in. It can be that permanent cookies are
blocked completely, while session cookies (without "Expires" attribute)
are still allowed.
* Though this is convenient, it is a security problem. That cookies are
not saved without setting "Expires" is really not a bug, a security
feature. I don't think it is a good idea to save a session cookie to disk.
If you close your browser and leave your PC, anybody else can recover your
session within the given session timeout.
* You get problems if the times and timezones on server and client are
out of sync. This cannot happen with the "Max-Age" attribute because it is
only a time delta.
Therefore, we reverted this in TurboGears (see
[
http://trac.turbogears.org/ticket/1729 ticket 1729]) and now set "Max-
age" again, instead of "Expires." We think that this should be changed in
CherryPy, too.
--
Ticket URL: <
http://www.cherrypy.org/ticket/794>
CherryPy <
http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework