Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
aee1759e
Commit
aee1759e
authored
Nov 20, 2001
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed API programming docs. This is now covered in the Zope Book.
parent
1387bfb5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
66 deletions
+0
-66
lib/python/Products/Sessions/help/sessionapi-prog.stx
lib/python/Products/Sessions/help/sessionapi-prog.stx
+0
-66
No files found.
lib/python/Products/Sessions/help/sessionapi-prog.stx
deleted
100644 → 0
View file @
1387bfb5
Session API Programming
Overview
Sessions allow you to maintain state associated with anonymous
users between requests. A session is a temporary "scratch" area
in which you can store information related to a site visitor.
A "session" ends when a visitor who begins a session neglects to
revisit your site in some number of minutes.
Usage
Developers will usually interact with the SESSION object stored
in REQUEST in order to perform session-related tasks.
More infrequently, developers will interact directly with
Browser Id Manager and Session Data Manager objects.
Common Programming
In order to manipulate session data, you interact with the
REQUEST.SESSION object.
For example, in DTML you might::
<dtml-with SESSION mapping>
<dtml-var cart missing="You have no cart">
</dtml-with>
or even more simply::
<dtml-var SESSION>
This would print the cart object in the session, or the entire SESSION
object. You could set an object in the session similarly to how you
set it in the REQUEST::
<dtml-call expr="SESSION.set('cart','this is really more of a wagon')">
You may change the name of the SESSION object in the management screens
for the session data object. You can do more complex operations on
SESSION data with python scripts, e.g.::
session = context.REQUEST.SESSION
cart = session.get('cart',()) # Get our cart or an empty list
cart.append(('my line item',100.00))
session['cart'] = cart # force a save back to the session
Tips
Keep in mind that SESSION objects are a lot like dictionaries; if
you wish to iterate through them in the context of a dtml-in expression,
you should use something like::
<dtml-in expr="SESSION.items()">
<dtml-var sequence-key>: <dtml-var sequence-item>
</dtml-in>
See Also
- "Session API":SessionInterfaces.py
- "Transient Object API":../../Transience/Help/TransienceInterfaces.py
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment