Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 54 lines (39 sloc) 1.366 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<erl>
out(A) -> {ssi, "TAB.inc", "%%",[{"pcookie", "choosen"}]}.
</erl>


<div id="entry">

<h1>Persistent Cookies</h1>
  <p>
    We saw in the first <a href="cookies.yaws">cookie</a> example, how we
    assigned a special erlang process to handle each session.
    The cookie has an expiry date, and the correct thing would be to let the
    handling process live as long as the cookie is valid. This is not a good option.
    A better option is to store cookie in a persistant storage. This can be an
    ets table or a dets table. If we choose an ets table, the cookies will disappear
    when the yaws server is restarted, whereas if we choose a dets table,
    the cookies will survive daemon restarts. What to choose depends on the
    type of cookie information we have.
  </p>

  <p>
    The yaws code in
    <a href="setpcookie.yaws">setpcookie.yaws</a> sets the cookie in the browser.
  </p>

  <p>And the yaws code in <a href="readpcookie.yaws">readpcookie.yaws</a>
    will read the cookie
  </p>

  <p>
    Let's show some code. To set the cookie we we have:
  </p>

<erl>
out(A) -> yaws_api:pre_ssi_files(A#arg.docroot, ["setpcookie.yaws"]).
</erl>

<p>
And to read the cookie, we have the following code:
</p>

<erl>
out(A) -> yaws_api:pre_ssi_files(A#arg.docroot, ["readpcookie.yaws"]).
</erl>


</div>


<erl>
out(A) -> {ssi, "END2",[],[]}.
</erl>

Something went wrong with that request. Please try again.