cookie username : string
table lastVisit : { User : string, When : time }
PRIMARY KEY User
fun main () =
userO <- getCookie username;
list <- queryX (SELECT * FROM lastVisit)
(fn r => {[r.LastVisit.User]} | {[r.LastVisit.When]} |
);
return
Cookie: {[userO]}
Set cookie value
Record your visit
and set r =
setCookie username r.User;
main ()
and imHere () =
userO <- getCookie username;
case userO of
None => return You don't have a cookie set!
| Some user =>
dml (DELETE FROM lastVisit WHERE User = {[user]});
dml (INSERT INTO lastVisit (User, When) VALUES ({[user]}, CURRENT_TIMESTAMP));
main ()