Skip to content
RobeeeJay edited this page Oct 1, 2012 · 4 revisions

This module maintains session data for the current request connection. You must include the Cookies module for this to work.

new fw.Session({ sessionKey: "sessionid", updateInterval: 60000, sessionTimeOut: 1200000 });

All arguments are optional.

sessionKey is a string that represents the name of the cookie used to store the guid key for this session, it defaults to "sid".

updateInterval is the time in milliseconds that sessions should be checked for expiry. The default is once a minute.

Making this value too high may impact how long a session actually lasts, if it checks once an hour then even if the maximum length of a session is set to 10 minutes, it could theoretically take 49 minutes for that session to expire.

Also, this interval is not exact, it is the time from the end of one scan to see if sessions has expired, to the beginning of the next scan. That shouldn't matter though.

sessionTimeOut is the length of time in milliseconds that after which a session can be expired by the interval scanning.

Simple Example

var stackFull = new fw.Stack();

stackFull.append(new fw.Cookie())
         .append(new fw.Session());

Unless a connection blocks cookies, a session object will be created and added to request.session. Any data stored there, such as request.session.somestring = "yay" will be accessible across all connections from that browser until the session expires.

Clone this wiki locally