On 8/1/00 at 8:03 AM, [EMAIL PROTECTED] (Jacob Levy) wrote:

> OK, browsed the archives but came up dry on these two questions:
> 
> * How do I get cookies in my handler?
> * How do I return a cookie to the caller?

Hi,

I had this same question and wrote the following to help me figure it out.  I
created a directory under htdocs called 'cookie' and created the following .tml
and index.tml files to display both the current time and the time stored in the
returned cookie:

cookie/.tml:

# Load the doc package, which has the cookie handling routines
package require doc

proc show_time_cookie {} {
        #
        # Get the cookie named 'time' from any cookies returned with the
        # document.
        #
        set argv [Doc_Cookie time]

        set html "<UL>\n"
        foreach value $argv {
                #
                # There may be more than one cookie named time, so print them
                # all.
                #
                append html "\t<LI>Cookie time = $value</LI>\n"
        }
        append html "\t<LI>Current time = [clock format [clock seconds]]</LI>\n"
        append html "</UL>\n"

        return $html
}


cookie/index.tml

[show_time_cookie]
[Doc_SetCookie -name time -value [clock format [clock seconds]]; return]




Reply via email to