Yes, I read your cookie:it is "1" Your persistent info is
{"Wget/1.24.5",{{2024,4,3},{1,4,25}},{ok,{{127,0,0,1},59488}}}
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}}}.