The doc module has two high-level routines to support cookies inside
.tml templates.  Check out Doc_SetCookie and Doc_Cookie in the doc.tcl file.

Doc_SetCookie works by formatting the SetCookie header and passing it to
Httpd_SetCookie, which later injects that header into the HTTP response.
Actually, there is a bit of indirection going on, and if you need to set
cookies in an arbitrary domain handler then we ought to generalize things, 
perhaps.
What Doc_SetCookie does is save the cookie in the global page variable,
and then then after it processes the page it calls Httpd_SetCookie.
You could re-use Doc_SetCookie if you copy this bit of code into your
domain handler:

    if {[info exist page(cookie)]} {
        foreach c $page(cookie) {
            Httpd_SetCookie $sock $c
        }
    }

Doc_Cookie looks at env(HTTP_COOKIE), so if your domain handler calls
Cgi_SetEnv to set up the standard environment variables, then you
can call Doc_Cookie from your domain handler, too.


>>>Jacob Levy said:
 > 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?
 > 
 > Thanks! --JYL
 > (hopefully by now I'm really subscribed...)
 > 
 > 

--      Brent Welch     <[EMAIL PROTECTED]>
        http://www.ajubasolutions.com
        Scriptics changes to Ajuba Solutions
        scriptics.com => ajubasolutions.com


Reply via email to