Configurable session name

This commit is contained in:
Michael Snoyman 2012-04-07 23:01:29 +03:00
parent 8d0f429c62
commit 4ac413e419
2 changed files with 4 additions and 7 deletions

View File

@ -24,7 +24,6 @@ module Yesod.Internal
, runUniqueList , runUniqueList
, toUnique , toUnique
-- * Names -- * Names
, sessionName
, tokenKey , tokenKey
) where ) where
@ -98,9 +97,6 @@ newtype Body url = Body (HtmlUrl url)
tokenKey :: IsString a => a tokenKey :: IsString a => a
tokenKey = "_TOKEN" tokenKey = "_TOKEN"
sessionName :: IsString a => a
sessionName = "_SESSION"
type CssBuilderUrl a = (a -> [(Text, Text)] -> Text) -> Builder type CssBuilderUrl a = (a -> [(Text, Text)] -> Text) -> Builder
data GWData a = GWData data GWData a = GWData

View File

@ -699,17 +699,18 @@ clientSessionBackend :: Yesod master
-> Int -- ^ Inactive session valitity in minutes -> Int -- ^ Inactive session valitity in minutes
-> SessionBackend master -> SessionBackend master
clientSessionBackend key timeout = SessionBackend clientSessionBackend key timeout = SessionBackend
{ sbLoadSession = loadClientSession key timeout { sbLoadSession = loadClientSession key timeout "_SESSION"
} }
loadClientSession :: Yesod master loadClientSession :: Yesod master
=> CS.Key => CS.Key
-> Int -> Int -- ^ timeout
-> S8.ByteString -- ^ session name
-> master -> master
-> W.Request -> W.Request
-> UTCTime -> UTCTime
-> IO (BackendSession, SaveSession) -> IO (BackendSession, SaveSession)
loadClientSession key timeout master req now = return (sess, save) loadClientSession key timeout sessionName master req now = return (sess, save)
where where
sess = fromMaybe [] $ do sess = fromMaybe [] $ do
raw <- lookup "Cookie" $ W.requestHeaders req raw <- lookup "Cookie" $ W.requestHeaders req