if {[ns_conn method] eq "POST"} { ns_set put [ns_conn outputheaders] Set-Cookie "foo=[ns_urlencode [ns_set get [ns_getform] foo]]; Path=/" set page "<html><body>said.tcl</body></html>" } elseif {[regexp {foo=([^;]*)} [ns_set iget [ns_conn headers] cookie] match foo]} { set page "<html><body>you said: [ns_quotehtml [ns_urldecode $foo]]</body></html>" } else { set page "<html><body><form method='POST' action='said.tcl'><input name='foo'><input type='submit'></body></html>" } ns_return 200 text/html $page