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 / *.* / cookie.spy < prev    next >
Encoding:
Text File  |  2004-05-18  |  1.6 KB  |  58 lines

  1. [[.import name=cookie]]
  2. <html><body>
  3.   Managing cookies is simple. Use the following forms 
  4.   to create and destroy cookies. Remember to refresh 
  5.   once, because the cookie will only be transmitted on 
  6.   the <i>following</i> request.<br>
  7.   [[-- input forms --]]
  8.   <hr>
  9.   <form action="[[=request.uri('path')]]" method=post>
  10.     <table><tr>
  11.       <td align=right>Cookie name:</td>
  12.       <td><input type=text name=name></td>
  13.       <td>(required)</td>
  14.     </tr><tr>
  15.       <td align=right>value:</td>
  16.       <td><input type=text name=value></td>
  17.       <td>(required for set)</td>
  18.     </tr><tr>
  19.       <td align=right>expiration:</td>
  20.       <td><input type=text name=exp> seconds.</td>
  21.       <td>(optional)</td>
  22.     </tr><tr>
  23.       <td colspan=3>
  24.         <input type=submit name=operation value=set>
  25.         <input type=submit name=operation value=delete>
  26.         <input type=submit name=operation value=refresh>
  27.       </td>
  28.     </tr></table>
  29.   </form>
  30.   <hr>
  31.   [[-- show cookies --]]
  32.   Cookies: [[=len(cookie.get().keys())]]<br>
  33.   <table>
  34.     <tr>
  35.       <td><b>name</b></td>
  36.       <td><b>value</b></td>
  37.     </tr>
  38.     [[for c in cookie.get().keys(): {]]
  39.       <tr>
  40.         <td>[[=c]]</td>
  41.         <td>[[=cookie.get(c)]]</td>
  42.       </tr>
  43.     [[ } ]]
  44.   </table>
  45.   [[-- set cookies --]]
  46.   [[\
  47.     operation = request.post('operation')
  48.     if operation:
  49.       operation = operation[0]
  50.       name = request.post('name')[0]
  51.       value = request.post('value')[0]
  52.       if operation == 'set' and name and value:
  53.         cookie.set(name, value)
  54.       if operation == 'delete' and name:
  55.         cookie.delete(name)
  56.   ]]
  57. </body></html>
  58.