From: dmcnulty@... (Dan McNulty) Date: 2002-02-21T22:58:49+09:00 Subject: Re: dang it, CGI::Session is broken again Hmmmm, nope, no joy after changing session_key to session_id. The way I read the session.rb code is that if session_id is omitted, a key will be generated for you (which is good), but that a session_key *must* be provided. My web session bombs with an "Internal Error", but you can see what is happening by running the code from the command line: [cgiuser@0FEC2CAF cgi]$ ./test.rbx (offline mode: enter name=value pairs on standard input) junk=test /usr/lib/ruby/1.6/cgi/session.rb:108:in `initialize': session_id `a_test' is invalid (ArgumentError) from /usr/lib/ruby/1.6/cgi/session.rb:51:in `new' from /usr/lib/ruby/1.6/cgi/session.rb:51:in `initialize' from ./test.rbx:8:in `new' from ./test.rbx:8 -- Dan Alan Chen wrote in message news:<20020220234346.GA4224@digikata.com>... > 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 > > ------------------------------------------------------- > >