Cookies and Sessions
If you want to persist data among different pages you can use cookies or sessions.
Cookies are persisted on the client, while sessions on the server, so it really depends on what you are doing.
To send cookies to the browser use this:
date = new Date().format('Y.m.d H:i:s')
response.cookie('lastvisit',date)
To read cookies from the browser use this:
date = request.cookie('lastvisit')
response.write('Your last visit was on '+ date)
For sessions here is how you set values for later use:
/* session1.jss */
n = Math.floor(Math.random()*4)
name = ['John','Jeff','Tony','Paul'][n]
require('session')
session.set('name',name)
response.write('<h1>Hello '+name+'</h1>'+
'<a href="session2.jss">Next page »</a>')
And here is how you get values from the session:
/* session2.jss */
require('session')
name = session.get('name')
response.write('<h1>Welcome back '+name+'</h1>')
I haven't seen anything easier in my life!
