Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (42 sloc) 1.711 kb
f448988 @klacke ""
authored
1 <erl>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
2 out(A) ->
20ece13 @klacke more css hackery
authored
3 {ssi, "TAB.inc", "%%",[{"cookies", "choosen"}]}.
f448988 @klacke ""
authored
4 </erl>
5
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
6 <div id="entry">
7
f448988 @klacke ""
authored
8
9
e35a591 @klacke more w3c compliance
authored
10 <h1>Yaws and Cookies</h1>
11 <p>
12 Cookies are the means in HTTP to assign data to a session. A HTTP session
13 typically consists of many (and sometimes concurrent) TCP connections from the
14 client to the web server. The first time a client arrives to our webserver, we
15 issue the HTTP header <tt>Set-Cookie: var=someval</tt>. The browser will then in
16 subsequent connections to the same server pass this cookie "var=someval" in its
17 client side <tt>Cookie: var=someval</tt> header. We can thereby assign state to a
18 session, either through data actualy encoded into the cookie value itself, or by
19 associating server side session data to the cookie.</p>
20 <p>
21
22 Let's do an example where we set a simple cookie, and create a specific erlang process
23 which is then responsible for that session.
24 The cookie value will be a string encoding of the pid handling the session.
25 </p>
26 <p>
27 The yaws code in
28 <a href="setcookie.yaws">setcookie.yaws</a> sets the cookie in the browser.</p>
29
30 <p>And the yaws code in <a href="readcookie.yaws">readcookie.yaws</a>
31 will read the cookie
32 and report some uninteresting session data.
33 </p>
34
35 <p>
36 A correct definition of cookies can be found at Netscapes
37 <a href="http://www.netscape.com/newsref/std/cookie_spec.html">cookie spec</a></p>
38
39
40 <p>The code to set the cookie looks like:</p>
d69e4d8 @klacke ""
authored
41
42 <erl>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
43 out(A) ->
44 {ok, B} = file:read_file(A#arg.docroot ++ "/setcookie.yaws"),
45 {ehtml,
46 {'div', [{class, "box"}],
47 {pre,[], B}}}.
48
d69e4d8 @klacke ""
authored
49 </erl>
50
51
52
53
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
54 </div>
55
56
57 <erl>
58 out(A) -> {ssi, "END2",[],[]}.
59 </erl>
d69e4d8 @klacke ""
authored
60
Something went wrong with that request. Please try again.