#!/usr/bin/env python # show python where the web modules are import sys sys.path.append('../') sys.path.append('../../../') import web, web.session, os session = web.session.start( storage='file', app='test', dir='../doc/src/lib/example-web-session', expire=10, ) print "Content-type: text/html\n\n" if session.created: print """

This is your first visit

Setting variable1 to 'Python Rules!'.

Refresh this page...

""" session['variable1'] = 'Python Rules!' else: if web.cgi.has_key('destroy'): session.destroy() print """

Session Deleted

Start again.

"""%(os.environ['SCRIPT_NAME']) else: print """

Welcome back

variable1: %s

Destroy session.

"""%(session['variable1'],os.environ['SCRIPT_NAME'])