"Stephen A Readman" <[EMAIL PROTECTED]> writes:
> I'm pretty new to mod_dtcl, but I can't seem to set cookies
> properly, basically I've written a module that allows users to
> browse the servers directory structure, but I want to use a cookie
> to store the last directory the user browsed and present it to them
> next time they visit the page.
> The cookie seems to persist for the duration of the client, but once
> I destroy and restart my browser - no cookie??
Hrm, I think I recall someone having a similar problem, once upon a
time. You might check to make sure the cookie looks right (follow the
server interaction with a system call trace on the apache process, or
something similar). I wonder if it's a browser problem? You might
also look through the list archives...
> <?
> headers setcookie "foo" "bar" # we have to put this before any 'hputs' statements
> hgetvars
> if {! [var exists dir]} {
> #Check for the cookie
> if { [ array exists COOKIES ] } {
> if { [array get COOKIES DirBrowserDir] != "" } {
> #Found the cookie var - use it
> set gstrDir [lindex [array get COOKIES DirBrowserDir] end]
> } else {
> #Cookie var wasn't found - default the dir
> set gstrDir {/}
> }
> } else {
> #no cookie array - default the dir
> set gstrDir {/}
> }
> } else {
> #Use the var passed in
> set gstrDir [var get dir]
> if {$gstrDir == ""} {
> set gstrDir {/}
> }
> }
> #Remember the dir for next session
> headers setcookie -name "DirBrowserDir" -value $gstrDir
maybe put an expiration time?
> # once buffering is switched off, it is no longer possible to
> # maninuplate headers
> buffered off
--
David N. Welton
Consulting: http://www.dedasys.com/
Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
Apache Tcl: http://tcl.apache.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]