Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added example usage of cookies to hello app.

  • Loading branch information...
commit ce09c604f6948d18662f9a1f0c8d600e178146c5 1 parent 5bb8cf9
@thatismatt authored
View
12 examples/hello/controllers/home.js
@@ -19,3 +19,15 @@ this.another = function() {
this.redir = function() {
return redirect('/product/details/1');
};
+
+this.cookie = function() {
+ var aCookie = this.cookie.get('a') === 'red' ? 'blue' : 'red';
+ var bCookie = (parseInt(this.cookie.get('b'), 10) || 0) + 1;
+ this.cookie.set('a', aCookie);
+ this.cookie.set('b', bCookie);
+ return view({
+ title: 'Cookies',
+ a: aCookie,
+ b: bCookie
+ });
+};
View
6 examples/hello/views/home/cookie.html
@@ -0,0 +1,6 @@
+<p>
+ The cookie a's value is: <%= a %>
+</p>
+<p>
+ The cookie b's value is: <%= b %>
+</p>
View
1  examples/hello/views/master.html
@@ -11,6 +11,7 @@
<li><a href="/home/another">An action sharing a view</a></li>
<li><a href="/product">List of products</a></li>
<li><a href="/error">Throw an error</a></li>
+ <li><a href="/home/cookie">Cookie example</a></li>
</ul>
<div class="main">
<%= main %>
Please sign in to comment.
Something went wrong with that request. Please try again.