From: pharrington Date: 2009-08-15T01:10:05+09:00 Subject: Re: CGI::Session weird behavior On Aug 14, 9:55 am, Bruno Sousa wrote: > Hi, > If I uncomment line 14 nothing is displayed and each time the page is > refreshed ( 2 second interval) ruby creates a different file > /tmp/rubysess.* > But if I uncomment lines 17-23 it works, displaying the last access time > and only one session file is created. > Why is that? I don't want to use cgi.out{} and stuff :( > >   1 <% >   2 require 'cgi' >   3 require 'cgi/session' >   4 require 'cgi/session/pstore' >   5 cgi = CGI.new("html4") >   6 >   7 sess = CGI::Session.new( cgi, 'database_manager' => > CGI::Session::PStore, >   8                               "session_key" => "a_test", >   9                               "session_expires" => Time.now + 1 * > 60, >  10                               "prefix" => "rubysess.") >  11 lastaccess = sess["lastaccess"].to_s >  12 sess["lastaccess"] = Time.now >  13 >  14 #print ''+lastaccess+'' >  15 >  16 =begin >  17 cgi.out{ >  18   cgi.html { >  19     cgi.body(){ >  20       "Last access time: #{lastaccess}" >  21     } >  22   } >  23 } >  24 =end >  25 >  26 sess.close >  27 >  28 %> > -- > Posted viahttp://www.ruby-forum.com/. If don't want to use cgi.out, you'd need to at least send back some http headers (at least Content-type) for anything to reach the user. (also, I don't know why you're using cgi = CGI.new("html4") if you don't want the html helpers, but :\ )