Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (36 sloc) 1.088 kb
d69e4d8 Claes Wikstrom ""
authored
1 <html>
2
3 <h2> Read persitant cookie </h2>
4
5 <erl>
6
7 to_integer(S) ->
8 list_to_integer(string:strip(S, both)).
9
10 out(A) ->
11 H=A#arg.headers,
12 C = H#headers.cookie,
13 io:format("Cookie =~p~n", [C]),
961926f Claes Wikstrom ""
authored
14 L=case yaws_api:find_cookie_val("pfoobar", C) of
d69e4d8 Claes Wikstrom ""
authored
15 [] ->
16 f("<p> No cookie set from the browser, need to "
17 "visit <a href=\"/setpcookie.yaws\">setpcookie.yaws</a> "
18 "to set the cookie first ~n", []);
961926f Claes Wikstrom ""
authored
19 NumStr ->
20 Num = to_integer(NumStr),
21 case ets:lookup(pcookies, {cookie,Num}) of
22 [{{cookie, Num}, Data}] ->
23 f("<p> Yes, I read your cookie:it is ~p~n "
24 "Your persistant info is ~n"
25 "<pre>~n~p~n</pre>~n", [NumStr, Data]);
26 [] ->
27 f("<p> You had a cookie,but the data is gone",[])
d69e4d8 Claes Wikstrom ""
authored
28 end
29 end,
3b9e4a1 Claes Wikstrom new ret vals from out/1
authored
30 {html, L}.
d69e4d8 Claes Wikstrom ""
authored
31
32 </erl>
33
34
35 <p>
36 The code to read the cookie, is simple, we get the cookie passed to the yaws
37 code in the #arg structure which is the argument supplied to the out/1 function.
38 The code is:
39 <erl>
40 out(A) ->
41 yaws_api:pre_ssi_files(A#arg.docroot, ["readpcookie.yaws"]).
42 </erl>
43
44
45 </html>
46
47
48
49
50
51
52
Something went wrong with that request. Please try again.