tcl-mod_dtcl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen A Readman" <>
Subject Vanishing cookies??
Date Mon, 08 Jul 2002 12:44:37 GMT

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
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??

Thanks in advance,


    Stephen A. Readman    Email:

    Seven Layer Communications Ltd.
    Edinburgh, EH30 9TG.  Tel:+44-(0)131-331-7777    Fax:+44-(0)131-331-7772

headers setcookie "foo" "bar" # we have to put this before any 'hputs' statements

   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

# once buffering is switched off, it is no longer possible to
# maninuplate headers
buffered off

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message