annotate demo/cookie.ur @ 2227:adb49db02af4
Fix type in flush FFI call to option string (rather than string).
author |
Ziv Scully <ziv@mit.edu> |
date |
Tue, 31 Mar 2015 04:10:46 -0400 |
parents |
93315ac00394 |
children |
|
rev |
line source |
adamc@464
|
1 cookie c : {A : string, B : float, C : int}
|
adamc@464
|
2
|
adamc@464
|
3 fun set r =
|
adamc@1050
|
4 setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C},
|
adamc@1050
|
5 Expires = None,
|
adamc@1050
|
6 Secure = False};
|
adamc@464
|
7 return <xml>Cookie set.</xml>
|
adamc@464
|
8
|
adamc@1050
|
9 fun setExp r =
|
adamc@1050
|
10 setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C},
|
adamc@1050
|
11 Expires = Some (readError "2012-11-6 00:00:00"),
|
adamc@1050
|
12 Secure = False};
|
adamc@1050
|
13 return <xml>Cookie set robustly.</xml>
|
adamc@1050
|
14
|
adamc@1050
|
15 fun delete () =
|
adamc@1050
|
16 clearCookie c;
|
adamc@1050
|
17 return <xml>Cookie cleared.</xml>
|
adamc@1050
|
18
|
adamc@464
|
19 fun main () =
|
adamc@464
|
20 ro <- getCookie c;
|
adamc@465
|
21 return <xml><body>
|
adamc@465
|
22 {case ro of
|
adamc@465
|
23 None => <xml>No cookie set.</xml>
|
adamc@1050
|
24 | Some v => <xml>
|
adamc@1050
|
25 Cookie: A = {[v.A]}, B = {[v.B]}, C = {[v.C]}<br/>
|
adamc@1050
|
26 <form><submit value="Delete" action={delete}/></form>
|
adamc@1050
|
27 </xml>}
|
adamc@465
|
28 <br/><br/>
|
adamc@464
|
29
|
adamc@465
|
30 <form>
|
adamc@465
|
31 A: <textbox{#A}/><br/>
|
adamc@465
|
32 B: <textbox{#B}/><br/>
|
adamc@465
|
33 C: <textbox{#C}/><br/>
|
adamc@465
|
34 <submit action={set}/>
|
adamc@1050
|
35 </form><br/>
|
adamc@1050
|
36
|
adamc@1050
|
37 <form>
|
adamc@1050
|
38 <b>Version that expires on November 6, 2012:</b><br/>
|
adamc@1050
|
39 A: <textbox{#A}/><br/>
|
adamc@1050
|
40 B: <textbox{#B}/><br/>
|
adamc@1050
|
41 C: <textbox{#C}/><br/>
|
adamc@1050
|
42 <submit action={setExp}/>
|
adamc@465
|
43 </form>
|
adamc@465
|
44 </body></xml>
|