Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (38 sloc) 1.294 kb
<h2> Read persistent cookie </h2>
to_integer(S) ->
list_to_integer(string:strip(S, both)).
out(A) ->
C = H#headers.cookie,
L=case yaws_api:find_cookie_val("pfoobar", C) of
[] ->
f("<p> No cookie set from the browser, need to "
"visit <a href=\"setpcookie.yaws\">setpcookie.yaws</a> "
"to set the cookie first </p>~n", []);
NumStr ->
Num = to_integer(NumStr),
case ets:lookup(pcookies, {cookie,Num}) of
[{{cookie, Num}, Data}] ->
f("<p> Yes, I read your cookie:it is ~p~n "
"Your persistent info is ~n"
"<pre>~n~p~n</pre> </p>~n", [NumStr, Data]);
[] ->
f("<p> You had a cookie,but the data is gone </p>",[])
{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:</p>
out(A) ->
{ok, B} = file:read_file(A#arg.docroot ++ "/readpcookie.yaws"),
{'div', [{class, "box"}],
{pre,[], B}}}.
Jump to Line
Something went wrong with that request. Please try again.