ZSession is a server-side session object that stores all state in RAM.
Add to Zope Products Directory and restart Zope.
On starting Zope a ZSession object will be created and named ZSession. In all methods that want to use ZSession, put at the top of the method
<dtml-call ZSession>
for example in the standard_html_header. It only needs to be called once on the page.
This does a few things: It looks for a session cookie (by default called _ZSession, but that's something you can set). If it finds one, it checks the Session in memory. If it doesn't find a cookie, or it finds that the Session is a dud, it will create a new Session in RAM, then send back a cookie with that session in it.
Next, it creates a ZSessionObj called SESSION, and puts it in the REQUEST object, that is REQUEST['SESSION'] which is just like REQUEST['RESPONSE'].
<dtml-var "REQUEST['SESSION']">
This looks and acts like a dictionary, only it pulls its data out of RAM, and sets data in RAM.
It supports the following methods:
The method copy()' - Is not implemented.
From here on inside the document, you can do things like:
<dtml-call "SESSION.set('someitem', 'somevalue')">
<dtml-var "SESSION['someitem']">
ZSession can also be called with an argument of session_id. If set, this is the name of the session to use.
It can also be called with a couple of flags: noCookie will stop the code setting a cookie, while validSession will raise an exception if the session being requested does not already exist.
Each time the ZSession is called the cookie expiry time is updated to match the Session timeout period.
ZSession supports the method getName() - this returns the name of the current session.
The manage interface allows ZSession objects to be viewed, deleted and also delete individual keys from each ZSession.
Right now the ZSessionObj stores strings base64 encoded pickles, if you store an object such as a database connection object it will not encrypt it. You can then reference it again on future requested pages.
A ZSessionObj is created for each request
ZSession.log is also created in the var directory.
Anthony Baxter for writing SQLSession which much of ZSession is based on.