"Bermejo, Rodrigo" wrote:
> I am trying to create a CGI:Session , but I am having troubles
> understanding the CGI behavior.
> 
> I am trying to use the CGI class just to handle session information, and
> use a simple 'print'
> to generate  my html document,
> 
> After creating  a CGI object it takes control of  the STDOUT ?
> 
> #!/usr/bin/env ruby
> #----------------->
> #Abstraction of my problem
> #This code does not work
> def head(title)
>        require 'cgi'
>        require 'cgi/session'
>         print "Content-type: text/html\r\n\r\n"
> 
>        #Session handling
>          cgi=CGI::new("html3")
>          session=CGI::Session(cgi)
>          print  "You are logged in as: #{session[\"login\"]}" if
> session["login"]
> 
>          html_out= "<HTML>" +
>                                  "<TITLE>#{title}</TITLE>" +
>                                 "<head>"
>        print    html_out
> 
> end
> #-----------------<

I recently scratched a similar headache in mod_ruby w/ eruby. The CGI
object needs a chance to output some headers, which will include the
cookie-setting headers. 

In my case, calling CGI#header worked nicely. (Instead of the whole
Content-type caboodle.)

HTH

-- 
(\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
( \__\_/__/ ) _)Industrial economics and technological management(
 \____/_\____/ (____engineering.discipline_=_Computer::Technology___)