r7088: start on some real structure for the SWAT web pages
[sfrench/samba-autobuild/.git] / swat / esptest / session.esp
1 <% page_header("columns", "ESP session test"); %>
2
3 <h1>Samba4 session test</h1>
4
5 <form name="SessionTest" method="POST" action="@@request['SCRIPT_NAME']"> 
6     Name:   <input name="Name"  type="text" value=""><br>
7     Value:  <input name="Value" type="text" value=""><br>
8     Timeout: <input name="Timeout" type="text" value=""><br>
9     <input name="submit" type="submit" value="Append">
10     <input name="submit" type="submit" value="Reset">
11     <input name="submit" type="submit" value="Destroy">
12     <input name="submit" type="submit" value="Cancel"><br>
13 </form>
14
15 <%
16   /* if its a post then the user has filled in the form, so
17      report the values 
18   */
19 if (request['REQUEST_METHOD'] == "POST") {
20         /* if they cancelled then take them back to the list of tests */
21         if (form['submit'] == "Cancel") {
22                 redirect("/");
23         }
24         
25         name  = form['Name'];
26         value = form['Value'];
27         timeout = form['Timeout'];
28         
29         if (timeout) {
30                 useSession(timeout);
31         }
32         
33         if (form['submit'] == "Reset" && name) {
34                 session[name] = null;
35         }
36         
37         if (form['submit'] == "Append" && name) {
38                 session[name] = "" + session[name] + value;
39         }
40         
41         if (form['submit'] == "Destroy") {
42                 destroySession();
43         }
44 }
45
46 function showArray(name, array) {
47         write("<h3>Array: " + name + "</h3>\n");
48         if (array == undefined) {
49                 write("undefined<br>\n");
50                 return;
51         }
52         for (v in array) {
53                 write(name + "[" + v + "]=" + array[v] + "<br>\n");
54         }
55 }
56
57 showArray("session", session);
58 write("SessionId=" + request['SESSION_ID'] + "<br>\n");
59 %>
60
61 <% page_footer(); %>