diff tests/cookieSec.ur @ 734:f2a2be93331c

Cookie signing working for forms
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Apr 2009 19:12:12 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/cookieSec.ur	Thu Apr 16 19:12:12 2009 -0400
@@ -0,0 +1,24 @@
+table t : {Id : int}
+
+cookie c : int
+
+fun setter r =
+    setCookie c (readError r.Id);
+    return <xml>Done</xml>
+
+fun writer () =
+    ido <- getCookie c;
+    case ido of
+        None => error <xml>No cookie</xml>
+      | Some id => dml (INSERT INTO t (Id) VALUES ({[id]}));
+                   return <xml>Done</xml>
+
+fun main () = return <xml><body>
+  <form>
+    <textbox{#Id}/> <submit value="Get cookie" action={setter}/>
+  </form>
+
+  <form>
+    <submit value="Write to database" action={writer}/>
+  </form>
+</body></xml>