Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (38 sloc) 1.294 kb
<html>
<h2> Read persistent cookie </h2>
<erl>
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("<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>",[])
end
end,
{html, L}.
</erl>
<p>
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>
<erl>
out(A) ->
{ok, B} = file:read_file(A#arg.docroot ++ "/readpcookie.yaws"),
{ehtml,
{'div', [{class, "box"}],
{pre,[], B}}}.
</erl>
</html>
Jump to Line
Something went wrong with that request. Please try again.