Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (46 sloc) 1.55 kb
<erl>
session(A, Visits) ->
receive
{From, tick} ->
N = calendar:local_time(),
From ! {self(), [N|Visits]},
session(A, [N|Visits])
after 60000 -> %% keep state for 60 secs only
exit(normal)
end.
out(A) ->
H = A#arg.headers,
C = H#headers.cookie,
case yaws_api:find_cookie_val("foobar", C) of
[] ->
Now = calendar:local_time(),
P = spawn(fun() -> session(A, [Now]) end),
yaws_api:setcookie("foobar",
pid_to_list(P), "/");
PidStr ->
Pid = list_to_pid(PidStr),
case process_info(Pid, messages) of
undefined ->
Now = calendar:local_time(),
P = spawn(fun() ->
session(A, [Now])
end),
yaws_api:setcookie("foobar",
pid_to_list(P), "/");
_ ->
ok
end
end.
</erl>
<html>
<h2> set cookie </h2>
<p>This is the page that set the cookie in the browser.
<a href="readcookie.yaws">readcookie.yaws</a> will
read the cookie and report persistent information as
long as the browser session exists.
<p> it will set the cookie
<tt>foobar = &lt;x,y,z&gt;; </tt> where the
x,y,z string is the textual representation of an
actual erlang pid which will be responsible for
this session.
</html>
Jump to Line
Something went wrong with that request. Please try again.