Cookie expire dates fixed

This commit is contained in:
Michael Snoyman 2010-11-14 16:28:30 +02:00
parent 09f1a03be2
commit f80cfab5d7
3 changed files with 8 additions and 3 deletions

View File

@ -45,6 +45,7 @@ module Yesod.Content
-- * Utilities
, formatW3
, formatRFC1123
, formatCookieExpires
#if TEST
, testSuite
#endif
@ -249,10 +250,14 @@ caseTypeByExt = do
Just typeHtml @=? lookup (ext "foo.html") typeByExt
#endif
-- | Format a 'UTCTime' in W3 format; useful for setting cookies.
-- | Format a 'UTCTime' in W3 format.
formatW3 :: UTCTime -> String
formatW3 = formatTime defaultTimeLocale "%FT%X-00:00"
-- | Format as per RFC 1123.
formatRFC1123 :: UTCTime -> String
formatRFC1123 = formatTime defaultTimeLocale "%a, %d %b %Y %X %Z"
-- | Format a 'UTCTime' for a cookie.
formatCookieExpires :: UTCTime -> String
formatCookieExpires = formatTime defaultTimeLocale "%a, %d-%b-%Y %X GMT"

View File

@ -385,7 +385,7 @@ headerToPair getExpires (AddCookie minutes key value) =
let expires = getExpires minutes
in ("Set-Cookie", charsToBs
$ key ++ "=" ++ value ++"; path=/; expires="
++ formatW3 expires)
++ formatCookieExpires expires)
headerToPair _ (DeleteCookie key) =
("Set-Cookie", charsToBs $
key ++ "=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT")

View File

@ -1,5 +1,5 @@
name: yesod
version: 0.6.1.2
version: 0.6.1.3
license: BSD3
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>