summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/cookie.cgi
diff options
context:
space:
mode:
authorEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
committerEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
commit094ca96844842928810f14844413109fc6cdd890 (patch)
treee60efbb980f38ba9308ccb4fb2b77b87bbc115f3 /web/src/cgi.tcl-1.10/example/cookie.cgi
downloadalpine-094ca96844842928810f14844413109fc6cdd890.tar.xz
Initial Alpine Version
Diffstat (limited to 'web/src/cgi.tcl-1.10/example/cookie.cgi')
-rwxr-xr-xweb/src/cgi.tcl-1.10/example/cookie.cgi45
1 files changed, 45 insertions, 0 deletions
diff --git a/web/src/cgi.tcl-1.10/example/cookie.cgi b/web/src/cgi.tcl-1.10/example/cookie.cgi
new file mode 100755
index 00000000..ea0709bc
--- /dev/null
+++ b/web/src/cgi.tcl-1.10/example/cookie.cgi
@@ -0,0 +1,45 @@
+#!/depot/path/tclsh
+
+# This CGI script shows how to create a cookie.
+
+package require cgi
+
+cgi_eval {
+ source example.tcl
+
+ cgi_input
+
+ cgi_http_head {
+ cgi_content_type text/html
+ if {0==[catch {cgi_import Name}]} {
+ cgi_export_cookie Name ;# expires=never
+ # For a persistent cookie, uncomment the "expires=never"
+ } else {
+ catch {cgi_import_cookie Name}
+ }
+ }
+ cgi_head {
+ cgi_title "Cookie Form Example"
+ }
+ cgi_body {
+ p "This form finds a value from a previous submission of \
+ the form either directly or through a cookie."
+ set Name ""
+
+ if {0==[catch {cgi_import Name}]} {
+ p "The value was found from the form submission and the cookie
+ has now been set. Bookmark this form, surf somewhere else
+ and then return to this page to get the value via the cookie."
+ } elseif {0==[catch {cgi_import_cookie Name}]} {
+ p "The value was found from the cookie."
+ } else {
+ p "No cookie is currently set. To set a cookie, enter a value
+ and press return."
+ }
+
+ cgi_form cookie {
+ puts "Value: "
+ cgi_text Name
+ }
+ }
+}