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 => <xml><tr><td>{[r.LastVisit.User]}</td> <td>{[r.LastVisit.When]}</td></tr></xml>); adamc@779: adamc@779: return <xml><body> adamc@779: Cookie: {[userO]}<br/> adamc@779: adamc@779: <table> adamc@779: <tr><th>User</th> <th>Last Visit</th></tr> adamc@779: {list} adamc@779: </table> adamc@779: adamc@779: <h2>Set cookie value</h2> adamc@779: <form><textbox{#User}/> <submit action={set}/></form> adamc@779: adamc@779: <h2>Record your visit</h2> adamc@779: <form><submit action={imHere}/></form> adamc@779: </body></xml> 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 <xml>You don't have a cookie set!</xml> 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: