Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (38 sloc) 1.128 kB
d69e4d8 @klacke ""
authored
1 <html>
2
d02b965 @klacke qnx port + docs overhaul by cschatz@networkadvantage.biz
authored
3 <h2> Read persistent cookie </h2>
d69e4d8 @klacke ""
authored
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,
961926f @klacke ""
authored
13 L=case yaws_api:find_cookie_val("pfoobar", C) of
d69e4d8 @klacke ""
authored
14 [] ->
15 f("<p> No cookie set from the browser, need to "
8e69e2c @klacke first almost working vsn of revproxy
authored
16 "visit <a href=\"setpcookie.yaws\">setpcookie.yaws</a> "
d69e4d8 @klacke ""
authored
17 "to set the cookie first ~n", []);
961926f @klacke ""
authored
18 NumStr ->
19 Num = to_integer(NumStr),
20 case ets:lookup(pcookies, {cookie,Num}) of
21 [{{cookie, Num}, Data}] ->
22 f("<p> Yes, I read your cookie:it is ~p~n "
d02b965 @klacke qnx port + docs overhaul by cschatz@networkadvantage.biz
authored
23 "Your persistent info is ~n"
961926f @klacke ""
authored
24 "<pre>~n~p~n</pre>~n", [NumStr, Data]);
25 [] ->
26 f("<p> You had a cookie,but the data is gone",[])
d69e4d8 @klacke ""
authored
27 end
28 end,
3b9e4a1 @klacke new ret vals from out/1
authored
29 {html, L}.
d69e4d8 @klacke ""
authored
30
31 </erl>
32
33
34 <p>
35 The code to read the cookie, is simple, we get the cookie passed to the yaws
36 code in the #arg structure which is the argument supplied to the out/1 function.
37 The code is:
20f2862 @klacke ""
authored
38
d69e4d8 @klacke ""
authored
39 <erl>
40 out(A) ->
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
41 {ok, B} = file:read_file(A#arg.docroot ++ "/readpcookie.yaws"),
42 {ehtml,
43 {'div', [{class, "box"}],
44 {pre,[], B}}}.
d69e4d8 @klacke ""
authored
45 </erl>
46
47
48 </html>
49
50
51
52
53
54
55
Something went wrong with that request. Please try again.