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]}
{list}
User Last Visit

Set cookie value

Record your visit

and set r = setCookie username {Value = r.User, Expires = None, Secure = False}; 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 ()