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