Permalink
Browse files

""

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@310 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent fdbcd74 commit 0d158e532159017d08859bfeb225ef9a6cce9e84 @klacke committed Nov 26, 2002
Showing with 67 additions and 3 deletions.
  1. +3 −0 www/EXHEAD
  2. +1 −1 www/code.yaws
  3. +1 −1 www/index.yaws
  4. +1 −1 www/pcookie.yaws
  5. +24 −0 www/session.yaws
  6. +37 −0 www/session1.yaws
View
@@ -8,10 +8,13 @@
<td> <A HREF="/query.yaws">Query part of url</a> </td>
<td> <A HREF="/form.yaws">Forms</a> </td>
<td> <A HREF="/redirect.yaws">Redirect</a> </td>
+</tr>
+<tr border="2">
<td> <A HREF="/arg.yaws">Arg</a> </td>
<td> <A HREF="/upload0.yaws">File upload</a> </td>
<td> <A HREF="/cookies.yaws">Cookies</a> </td>
<td> <A HREF="/pcookie.yaws">Persistant Cookies</a> </td>
+ <td> <A HREF="/session.yaws">Cookie sessions</a> </td>
<td> <A HREF="/shopingcart/index.yaws">Tiny shoping cart</a> </td>
</tr>
</table>
View
@@ -2,7 +2,7 @@
<erl>
out(A) ->
- Head = yaws_api:ssi(A#arg.docroot, ["/HEAD", "/TOPTAB"]),
+ Head = yaws_api:ssi(A#arg.docroot, ["/HEAD", "/EXHEAD"]),
L = yaws_api:parse_query(A),
{Code, F} = case lists:keysearch(file, 1, L) of
View
@@ -74,7 +74,7 @@ Yaws is fast, it delivers 3000 static/dynamic pages/sec on my 2Ghz home box.
<li><p> some backwards incompatible changes such as ssl config and
yaws_api:parse_post_data/1. See the docs for details.
<li><p> Arg rewrite, customized errors etc.
-<li><p> Lots of new documentation
+<li><p> Lots of new documentation and new examples
<li><p> Optimized ehtml generation
</ul>
View
@@ -12,7 +12,7 @@ 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 restarded, whereas if we choose a dets table,
+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.
View
@@ -0,0 +1,24 @@
+<erl>
+out(A) -> yaws_api:ssi(A#arg.docroot, ["/HEAD", "/EXHEAD"]).
+</erl>
+
+
+
+<h1>The session server</h1>
+<p>
+The Yaws session server is ideal (and recommended)
+for maintaining cookie state
+in a server side application.
+
+The code in <a href="/code.yaws?file=/session1.yaws">session1.yaws</a>
+shows a minimalistic way to handle sessions.
+To run it click <a href="/session1.yaws">here</a>
+
+
+
+
+
+</html>
+
+
+
View
@@ -0,0 +1,37 @@
+<erl>
+
+-record(myopaque, {udata,
+ times = 0,
+ foobar}).
+
+out(A) ->
+ H = A#arg.headers,
+ C = H#headers.cookie,
+ case yaws_api:find_cookie_val("baz", C) of
+ [] ->
+ M = #myopaque{},
+ Cookie = yaws_api:new_cookie_session(M),
+ Data = {ehtml,
+ {html,[],
+ ["I just set yout cookie to ", Cookie, "Click ",
+ {a, [{href,"/session1.yaws"}], "here"},
+ "to revisit"]}},
+ CO = yaws_api:setcookie("baz",Cookie,"/"),
+ [Data, CO];
+ Cookie ->
+ {ok, OP} = yaws_api:cookieval_to_opaque(Cookie),
+ OP2 = OP#myopaque{times = OP#myopaque.times + 1},
+ yaws_api:replace_cookie_session(Cookie, OP2),
+ Data = {ehtml,
+ {html,[],
+ [
+ "Click ",
+ {a, [{href,"/session1.yaws"}], "here"},
+ "to revisit",
+ {p, [], f("You have been here ~p times", [OP2#myopaque.times])},
+ {p, [], f("Your cookie is ~s", [Cookie])}]}},
+ Data
+ end.
+
+</erl>
+

0 comments on commit 0d158e5

Please sign in to comment.