Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 28 lines (23 sloc) 1.11 kB
caa17e6 @alsonkemp Adding Cookies and Sessions
authored
1 import Turbinado.Controller
2
3 createCounter :: Controller ()
4 createCounter = do clearLayout
5 setSessionValue "counter" "0"
6 setViewDataValue "show-me" "0"
7
8 incrementCounter :: Controller ()
9 incrementCounter = do clearLayout
10 e <- getEnvironment
11 setViewDataValue "show-session" $ show $ fromJust $ getSession e
12 c <- getSessionValue "counter"
13 case c of
14 Nothing -> setViewDataValue "show-me" "No counter found in session"
15 Just c' -> do let ctr = read c' :: Int
16 setSessionValue "counter" (show $ ctr + 1)
17 setViewDataValue "show-me" $ show (ctr+1)
18
19 deleteCounter :: Controller ()
20 deleteCounter = do clearLayout
21 deleteSessionKey "counter"
22 setViewDataValue "show-me" "deleted"
1895b2f @alsonkemp Fixes for cookies and cookiesessions
authored
23
24 abandonCounter :: Controller ()
25 abandonCounter = do clearLayout
26 abandonSession
27 setViewDataValue "show-me" "abandoned"
Something went wrong with that request. Please try again.