Updated 2013-11-28 23:35:06 by pooryorick

The ncgi package provides commands that manipulate CGI values. These are values that come from Web forms and are processed either by CGI scripts or web pages with embedded Tcl code. Use the ncgi package to query these values, set and get cookies, and encode and decode www-url-encoded values. (From the man page [1])

Documentation can be found at http://tcllib.sourceforge.net/doc/ncgi.html

Undocumented, but fairly important, is the need to call ::ncgi::header (or ::ncgi::redirect) after ::ncgi::setCookie, else the cookie does not set. Jan. 13, 2010
#!/usr/bin/env tclsh8.4
package require ncgi
::ncgi::setCookie -name test -value THisIsAGoodCookie -domain yourdomain.com -expires "july 20, 2010" -path /
#NOTE: Must use ncgi::header else cookie never sets. 
#ALSO: The following two are similar, but not the same.
#puts "Content-Type: text/plain\n"

puts "cookie: [::ncgi::cookie test]"

recently on comp.lang.tcl, aku mentioned that ncgi came about by starting with Don Libes' cgi.tcl and breaking the code into namespaces and 3 modules.

Related modules in tcllib are