From: Alan Chen Date: 2002-02-21T08:32:53+09:00 Subject: Re: dang it, CGI::Session is broken again On Thu, Feb 21, 2002 at 07:19:12AM +0900, Dan McNulty wrote: > What is wrong with this? I swear this was working yesterday, but now > its broken. I have a feeling something changed in my environment, and > that this will work as expected for others...perhaps the web gods have > cursed me, and I am destined for a future of never-working code :-( > > For me, after rerunning this program sess["junk"] is always "nil". > The session is never restored. > > I am sorry for bringing this subject up again, but this is absolutely > maddening! > > ---------------------------------------------------- > #!/usr/bin/ruby > > require "cgi" > require "cgi/session" > > cgi = CGI.new > > sess = CGI::Session.new(cgi, > "session_key" => "a_test", Replace session_key with session_id. session_key is a valid option for CGI sessions, but I'm not sure of the semantics after a glance at the session code -- more details in the lib of the ruby installation /usr/lib/ruby/1.6/cgi/session.rb on my Debian system. > "prefix" => "rubysess.") > > if sess["junk"]==nil > print "A new session ", "junk is ", sess["junk"], "\n" > sess["junk"]=123 > print "A new session ", "junk is now ", sess["junk"], "\n" > sess.close > else > print "An existing session", "junk is ", sess["junk"], "\n" > sess["junk"]=sess["junk"].to_i + 1 > print "An existing session", "junk is now ", sess["junk"], "\n" > sess.close > end > ------------------------------------------------------- > -- Alan Chen Digikata LLC http://digikata.com