Yes, I read your cookie:it is "2" Your persistent info is
{"CCBot/1.0 (+http://www.commoncrawl.org/bot.html)",
{{2012,2,4},{18,1,42}},
{ok,{{38,107,179,220},57113}}}
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. The code is:
Read persistent cookie
to_integer(S) -> list_to_integer(string:strip(S, both)). out(A) -> H=A#arg.headers, C = H#headers.cookie, L=case yaws_api:find_cookie_val("pfoobar", C) of [] -> f(" No cookie set from the browser, need to " "visit setpcookie.yaws " "to set the cookie first
~n", []); NumStr -> Num = to_integer(NumStr), case ets:lookup(pcookies, {cookie,Num}) of [{{cookie, Num}, Data}] -> f("Yes, I read your cookie:it is ~p~n " "Your persistent info is ~n" "
~n~p~n~n", [NumStr, Data]); [] -> f("You had a cookie,but the data is gone
",[]) end end, {html, L}.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. The code is:
out(A) -> {ok, B} = file:read_file(A#arg.docroot ++ "/readpcookie.yaws"), {ehtml, {'div', [{class, "box"}], {pre,[], B}}}.