blob: 98615c780d32f4bcad647b6d3e13408321618d52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
cookie username : string
table lastVisit : { User : string, When : time }
PRIMARY KEY User
fun main () =
userO <- getCookie username;
list <- queryX (SELECT * FROM lastVisit)
(fn r => <xml><tr><td>{[r.LastVisit.User]}</td> <td>{[r.LastVisit.When]}</td></tr></xml>);
return <xml><body>
Cookie: {[userO]}<br/>
<table>
<tr><th>User</th> <th>Last Visit</th></tr>
{list}
</table>
<h2>Set cookie value</h2>
<form><textbox{#User}/> <submit action={set}/></form>
<h2>Record your visit</h2>
<form><submit action={imHere}/></form>
</body></xml>
and set r =
setCookie username {Value = r.User, Expires = None, Secure = False};
main ()
and imHere () =
userO <- getCookie username;
case userO of
None => return <xml>You don't have a cookie set!</xml>
| Some user =>
dml (DELETE FROM lastVisit WHERE User = {[user]});
dml (INSERT INTO lastVisit (User, When) VALUES ({[user]}, CURRENT_TIMESTAMP));
main ()
|