IIRC printing the debug information to the stdout (default for class Session) 
causes the headers to be sent before the actual content is generated. 

You can either switch off the debug messages printed by SESSION or use the -
debugFile to redirect the output to your disk. 

A common way to do so is to assign a name that includes the child pid in order  
to avoid debug filename clashing among children.

set dbgfile     [file join / tmp session-ctcl_debug-[pid].log ]
set dbgf        [open $dbgfile a]
....

SESSION configure -debugFile $dbgf -debugMode 1 ......

look at the manual page for the Session package.

 -- Massimo

On Mon, 10 Jan 2011 15:41:39 +0300, Cyril Shtumf wrote
> Hi! Work with the sessions always returns an error "Cannot 
> manipulate headers - already sent". Please help! My Apache config 
> looks like this:
> 
> <VirtualHost *:8080>
> 
>          ServerAdmin [email protected]
>          ServerAlias *.somesite.com
>          ServerName  somesite.com
>          UseCanonicalName On
> 
>          CustomLog 
> /home/webserver/somesite/www/logs/access_log.apache.log combined
>          ErrorLog /home/webserver/somesite/www/logs/errors_log.apache.log
>          TransferLog 
> /home/webserver/somesite/www/logs/transfers_log.apache.log
> 
>          DocumentRoot /home/webserver/somesite/www/html/
> 
>          RivetServerConf ChildInitScript "package require DIO; 
> ::DIO::handle Mysql db -user xxx -host localhost -db xxx -pass xxx"
> 
>          RivetServerConf ChildInitScript "package require Session; 
> Session SESSION -entropyFile /dev/random -entropyLength 10 
> -debugMode 1 -dioObject db -sessionTable session"
> 
> <Directory "/home/webserver/somesite/www/html/">
>                  RivetDirConf BeforeScript "SESSION activate"
>                  AllowOverride All
>                  Options +FollowSymLinks +ExecCGI
>                  Order allow,deny
>                  Allow from all
>                  DirectoryIndex index.html index.htm index.rvt
> </Directory>
> 
> <Files ~ "^\.ht">
>                  Order allow,deny
>                  Deny from all
>                  Satisfy All
> </Files>
> 
> </VirtualHost>
> 
> And regardless of the script I get:
> 
> ::SESSION (debug) activate: checking out the situation
> ::SESSION (debug) id: no session cookie 'rivetSession'
> ::SESSION (debug) activate: new session, reason 'no_cookie'
> ::SESSION (debug) get_entropy_bytes: returning 'e978a8ca70f1890a874a'
> ::SESSION (debug) gen_session_id - feeding this to md5: 
> '12946631424269354032127.0.0.11294663142some random 
> stringe978a8ca70f1890a874a'
> ::SESSION (debug) create_session: ip 127.0.0.1, id 
> '8DF5C83A062ACB5922CFC89EEA758E7D'
> 
> ------------------------------------------------------------------------
> Cannot manipulate headers - already sent
>      invoked from within
> "headers add $cookieKey $cookieValue"
>      ("set" arm line 18)
>      invoked from within
> "switch -- $cmd {
>       "set" {
>           set value [lindex $args 0]
>           set args  [lrange $args 1 end]
>           import_keyvalue_pairs params $args
> 
>           if {[regex..."
>      (procedure "cookie" line 4)
>      invoked from within
> "cookie set $cookieName $value  -path $cookiePath  -minutes 
> $cookieLifetime  -secure $cookieSecure"
>      (object "::SESSION" method "::Session::set_session_cookie" body 
> line 2)     invoked from within "set_session_cookie $id"
>      (object "::SESSION" method "::Session::activate" body line 23)  
>    invoked from within "SESSION activate"
> ------------------------------------------------------------------------
> 
> *OUTPUT BUFFER:*
> 
> SESSION activate
> namespace eval request {
> puts -nonewline ""
> 
> puts "Hello world!";
> 
> puts -nonewline "
> 
> "
> 
> }


--


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to