Module stick/middleware/session
This module provides middleware for HTTP sessions.
It adds a session property to the request object that allows to store
arbitrary data on on a per-visitor basis.
The default session implementation is based on Java Servlet sessions.
This can be overridden by setting the app.session.impl property to an
alternative session constructor.
app.session.impl = MySession;
The session constructor will be called with the request object as only argument when the session is first accessed.
Functions
- middleware(next, app)
Class ServletSession
ServletSession (request)
An HTTP session object based on top of servlet sessions. Properties of the session's data object are persisted between requests of the same client.
Parameters
| request | a JSGI or servlet request object |
ServletSession.prototype.data
A container for things to store in this session between requests.
ServletSession.prototype.isNew
True if this session was created in the current request. This can be useful to find out if the client has cookies disabled for cookie-based sessions.
middleware (next, app)
This middleware provides support for anonymous user sessions.
Parameters
| Function | next | the wrapped middleware chain |
| Object | app | the Stick Application object |
Returns
| Function | a JSGI middleware function |
request.session
A session object for the current request. If no session exists a new one will be created.