Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. I am struggling to understand sessions in CherryPy
  2. ...
  3. from mod_python import Session
  4. sess = Session.Session(req, timeout = 60*60, lock=0)
  5. #req is the request page object.
  6.        
  7. cherrypy.config.update({
  8.     'tools.sessions.on': True,
  9.     'tools.sessions.storage_type': 'ram'})
  10.        
  11. import cherrypy
  12. from cherrypy.lib import sessions
  13.  
  14. def index(sid=0, secret=None, timeout=30, lock=1):
  15.     cherrypy.session['test'] = 'test'
  16.     cherrypy.lib.sessions.expire()
  17.     return cherrypy.session.get('test','None')
  18.        
  19. sess = cherrypy.session
  20. sess['_cp_username'] = None
  21.        
  22. cherrypy.session.regenerate()
  23. cherrypy.session['_cp_username'] = cherrypy.request.login