home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / spyce / *.* / session.spy < prev    next >
Encoding:
Text File  |  2004-05-18  |  860 b   |  29 lines

  1. [[.import name=cookie]]
  2. [[.import name=session args="'session_dir', '/tmp'"]]
  3. <html><body>
  4.   [[-- retrieve session information --]]
  5.   [[\
  6.     sessionid = cookie.get('session')
  7.     if sessionid:
  8.       num = session.get(sessionid)
  9.       if num==None:
  10.         sessionid = None
  11.         num = 0
  12.       else: num = int(num)
  13.     else: num = 0
  14.   ]]
  15.   [[-- output --]]
  16.   Your session ID was: [[=sessionid]]<br>
  17.   [[num = num + 1]]
  18.   You have visited this page [[=num]] time(s).<br>
  19.   [[-- save session information for next time --]]
  20.   [[\
  21.     sessionid = session.set( num, 10, sessionid )
  22.     if sessionid: cookie.set('session', sessionid)
  23.   ]]
  24.   Your session ID is now: [[=sessionid]]<br>
  25.   Session expiration = 10 seconds.<br>
  26.   <b>Note:</b> This example requires write access to 
  27.   the /tmp directory to function correctly.
  28. </body></html>
  29.