view tests/cookieJsec.ur @ 2257:28a541bd2d23

Use referenced (rather than all) free variables as keys for pure caches.
author Ziv Scully <>
date Sun, 27 Sep 2015 14:46:12 -0400
parents 796e42c93c48
line wrap: on
line source
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]}))

fun preWriter () = return <xml><body onload={onConnectFail (alert "RPC error")}>
  <button onclick={writer ()} value="Write to database"/>

  <a link={main ()}>Back</a>

and main () = return <xml><body>
    <textbox{#Id}/> <submit value="Get cookie" action={setter}/>

  <form><submit action={preWriter} value="Prepare to write to database"/></form>