On 10/17/2018 01:44 AM, Andreas Schneider wrote:
> Hi
> 
> i'm very new to rivet.
> 
> on my first steps i want to use the session package..
> my setup i guess.. should be ok (Postgres DIO)
> 
> if i place "<HEAD> <? SESSION activate;?></HEAD>" on my  .rvt file at 
> first line
> i receive:
> 
> ::SESSION (debug) activate: checking out the situation
> ::SESSION (debug) id: no session cookie 'rivetSession'
> ::SESSION (debug) activate: new session, reason 'no_cookie'
> ::SESSION (debug) gen_session_id - feeding this to md5: 
> '1539593561266012674[MYIP]1539593561some random string'
> ::SESSION (debug) create_session: ip [MYIP], id 
> '659EDD383BEDE1BFCFF52A5ABBDC3378'
> 
> Cannot manipulate headers - already sent
>      invoked from within
> "headers add $cookieKey $cookieValue"
> 
> Best regards
> 
> Andreas
> 

Hi Andreas

I gather that somehow your code is sending data to the output channel 
before activating the session. Sending data causes the HTTP headers to 
be sent and therefore any subsequent attempt to change them for the same 
HTTP request is invalid because...it's too late...they have already gone...

The good practice is to do everything concerning the content preparation 
(session activation included) before the template is parsed. Parsing an 
rvt template generally implies the implicit execution of one or more 
'puts ...' commands even when you're not putting actual Tcl code in it. 
You can activate the session at the very beginning of the template or 
prevent the template from being overloaded with code and put this 
preamble in separate BeforeScript command (see 
http://tcl.apache.org/rivet/manual3.0/directives.html)

If you're running rivet 3.0 you can override the the whole request 
processing scheme by exploiting the RequestHandler configuration 
directive (see also http://tcl.apache.org/rivet/manual3.0/processing.html)

  -- Massimo Manghi
  • Session Tom Lloyd
    • session Andreas Schneider
      • Re: session Massimo MANGHI

Reply via email to