adamc@464: cookie c : {A : string, B : float, C : int} adamc@464: adamc@464: fun set r = adamc@1050: setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C}, adamc@1050: Expires = None, adamc@1050: Secure = False}; adamc@464: return <xml>Cookie set.</xml> adamc@464: adamc@1050: fun setExp r = adamc@1050: setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C}, adamc@1050: Expires = Some (readError "2012-11-6 00:00:00"), adamc@1050: Secure = False}; adamc@1050: return <xml>Cookie set robustly.</xml> adamc@1050: adamc@1050: fun delete () = adamc@1050: clearCookie c; adamc@1050: return <xml>Cookie cleared.</xml> adamc@1050: adamc@464: fun main () = adamc@464: ro <- getCookie c; adamc@465: return <xml><body> adamc@465: {case ro of adamc@465: None => <xml>No cookie set.</xml> adamc@1050: | Some v => <xml> adamc@1050: Cookie: A = {[v.A]}, B = {[v.B]}, C = {[v.C]}<br/> adamc@1050: <form><submit value="Delete" action={delete}/></form> adamc@1050: </xml>} adamc@465: <br/><br/> adamc@464: adamc@465: <form> adamc@465: A: <textbox{#A}/><br/> adamc@465: B: <textbox{#B}/><br/> adamc@465: C: <textbox{#C}/><br/> adamc@465: <submit action={set}/> adamc@1050: </form><br/> adamc@1050: adamc@1050: <form> adamc@1050: <b>Version that expires on November 6, 2012:</b><br/> adamc@1050: A: <textbox{#A}/><br/> adamc@1050: B: <textbox{#B}/><br/> adamc@1050: C: <textbox{#C}/><br/> adamc@1050: <submit action={setExp}/> adamc@465: </form> adamc@465: </body></xml>