## Read cookie

<erl> out(A) -> H=A#arg.headers, C = H#headers.cookie, L=case yaws_api:find_cookie_val("foobar", C) of [] -> f("

No cookie set from the browser, need to " "visit setcookie.yaws " "to set the cookie first ~n", []); PidStr -> Pid = list_to_pid(PidStr), Pid ! {self(), tick}, receive {Pid, VisitList} -> f("

Yes, I read your cookie " "You have vistited this page ~w times " "they were ~n

~n~s

~n " "Reloading this page will show the session state ", [length(VisitList), lists:map(fun(D) -> f("
- ~p~n", [D]) end, VisitList) ]) after 500 -> f("

  You had a cookie, but the pid handling your sess " "timedout ...",[]) end end, {html, L}. </erl>

  The code to read the cookie, is simple, we get the cookie passed to the yaws code in the #arg structure which is the argument supplied to the out/1 function.

  We use the `yaws_api:find_cookie_val/2` function to parse the raw cookie string passed to us from the browser. The code is: <erl> out(A) -> yaws_api:pre_ssi_files(A#arg.docroot, ["readcookie.yaws"]). </erl>