diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | flup/middleware/session.py | 6 |
2 files changed, 10 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2006-12-02 Allan Saddi <asaddi@sahara.flup.org> + + * Add forceCookieOutput attribute to SessionService to + force Set-Cookie output for the current request. + 2006-12-01 Allan Saddi <asaddi@europa.saddi.net> * Update setup script. diff --git a/flup/middleware/session.py b/flup/middleware/session.py index 9656136..c4396fe 100644 --- a/flup/middleware/session.py +++ b/flup/middleware/session.py @@ -540,6 +540,8 @@ class SessionService(object): necessary). service.cookieAttributes - Dictionary of additional RFC2109 attributes to be added to the generated cookie. + service.forceCookieOutput - Normally False. Set to True to force + output of the Set-Cookie header during this request. """ _expiredSessionIdentifier = 'expired session' @@ -552,6 +554,7 @@ class SessionService(object): self._cookieName = cookieName self._cookieExpiration = cookieExpiration self.cookieAttributes = dict(cookieAttributes) + self.forceCookieOutput = False self._fieldName = fieldName self._session = None @@ -615,7 +618,8 @@ class SessionService(object): def addCookie(self, headers): """Adds Set-Cookie header if needed.""" - if not self.encodesSessionInURL and self._shouldAddCookie(): + if not self.encodesSessionInURL and \ + (self._shouldAddCookie() or self.forceCookieOutput): if self._session is not None: sessId = self._sessionIdentifier() expireCookie = not self._session.isValid |