Cgi session management is foobar

If I just do:

require 'cgi'
require 'cgi/session'

cgi = CGI.new("html3")
sess = CGI::Session.new(cgi,
                         "new_session" => true,
                         "session_key" => "rubyweb",
                         "session_id" => "9650",
                         "prefix" => "web-session"
                       )

print "Content-Type: text/html\n\n"
print "<html><body>"
#puts sess.inspect
print "HTML content here"
print "</body></html>"

And run this script on the command line.

I get no html output beyond the Content-type line. Needless to say the cgi script too.

When I comment out the session creation line the script runs fine. What's wrong with this picture?

-Cere

Ok, I figured it out. I needed to flush stdout and close the session. :wink:

Cere Davis wrote:

···

If I just do:

require 'cgi'
require 'cgi/session'

cgi = CGI.new("html3")
sess = CGI::Session.new(cgi,
                        "new_session" => true,
                        "session_key" => "rubyweb",
                        "session_id" => "9650",
                        "prefix" => "web-session"
                      )

print "Content-Type: text/html\n\n"
print "<html><body>"
#puts sess.inspect
print "HTML content here"
print "</body></html>"

And run this script on the command line.

I get no html output beyond the Content-type line. Needless to say the cgi script too.

When I comment out the session creation line the script runs fine. What's wrong with this picture?

-Cere