Permalink
Browse files

Fix wrong max_age value, now auto-calculated by set_cookie based on d…

…atetime value of expires. Fixes #4. Thanks revlis
  • Loading branch information...
1 parent 26e6c61 commit c73e50a7c41dff5787155081297ec3820aebb433 @dhaaker committed Feb 25, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 auth_remember/utils.py
View
@@ -46,12 +46,16 @@ def preset_cookie(request, token_string):
def set_cookie(response, token):
- """Set the cookie with the remember token on the response object."""
- max_age = datetime.now() + timedelta(seconds=COOKIE_AGE)
- expires = cookie_date(time.time() + COOKIE_AGE)
+ """Set the cookie with the remember token on the response object.
+
+ The max_age value will be auto-calculated based on the datetime set via
+ expires.
+
+ """
+ expires = datetime.utcnow() + timedelta(seconds=COOKIE_AGE)
response.set_cookie(COOKIE_NAME, token,
- max_age=max_age, expires=expires,
+ max_age=None, expires=expires,
domain=settings.SESSION_COOKIE_DOMAIN,
path=settings.SESSION_COOKIE_PATH,
secure=settings.SESSION_COOKIE_SECURE or None,

0 comments on commit c73e50a

Please sign in to comment.