Is there some simple example how to use cookies or sessions in Tower.js? I read about Connect Middleware, but I have no experience with it (and unfortunately with Node.js also).
If examples are not available I will be grateful for any tips too.
Cookies
From the TowerJS source code here, the controller has these properties:
@request
@response
@cookies
(which is just a shortcut for @request.cookies
)@session
(which is just a shortcut for @request.session
)Hence to set cookies you can follow express documentation here
For example this set cookie 'rememberme'
# "Remember me" for 15 minutes
@response.cookie 'rememberme', 'yes',
expires: new Date(Date.now() + 900000)
httpOnly: true
And to get the cookie
@request.cookies.rememberme
Session
As for session, looks like it's just connect in memory session. See source code here https://github.com/viatropos/tower/blob/master/src/tower/server/application.coffee#L39
So you can just use it like:
@request.session.something = 'something'
or
@session.something = 'something'
Ok hope that helps...