From: "Daniel P. Zepeda" Date: 2002-02-20T16:30:24+09:00 Subject: Re: CGI::Session problems On Tue, 19 Feb 2002 22:38:33 +0900 dmcnulty@mindspring.com (Dan McNulty) wrote: > Nice extension, especially being able to set the expiry, which is > something I must do. Thank you. >Any idea if Matz is going to incorporate this > into the released version? Seems like a good addition to me. I do not know if it will be incorporated. I submitted it to this list a couple months ago, no-one commented on it at that time. I've also uploaded to the bug list (id 212), so I suppose it will make it in the main distribution if someone doesn't come up with something better. It would be a great honor, for me anyway, to even get this little bit of code into Ruby. > > -- Dan > > "Daniel P. Zepeda" wrote in message > news:<20020215212758.60a82cac.daniel@zepeda-zone.net>...> I wrote some > minor enhancements and fixes for the CGI::Session. You can find it and a > demonstration program at rubycookbook.org:> > > http://www.rubycookbook.org/showrecipe.rb?sessionID=jIYy8Oar1QLGIAtI&recipeID=135 > > > > On Sat, 16 Feb 2002 01:00:23 +0900 > > dmcnulty@mindspring.com (Dan McNulty) wrote: > > > > > Argh! > > > > > > I am trying to using CGI:Session (with Apache & mod_ruby) and > > > meeting no success. I have read what little there is about sessions > > > in the two books I have, and scoured the 'net for examples (and > > > found a few). > > > > > > The code I am using is like this: > > > > > > def getsession(cgi) > > > if $sess == nil then > > > $sess = CGI::Session.new(cgi, > > > "session_key" => "a_test", > > > "prefix" => "rubysess.") > > > end > > > return $sess > > > end > > > > > > cgi = CGI.new > > > sess = getsession(cgi) > > > if sess["junk"] != nil > > > puts "An existing session" > > > puts Marshal.load(sess["junk"]) > > > sess.update > > > else > > > puts "A new session" > > > sess["junk"]=123 > > > end > > > > > > The function getsession() is defined in a loaded file. > > > > > > The problem is that sess["junk"] is always nil, like session isn't > > > being stored or restored. > > > > > > I would really love a simple example of this working under mod_ruby. > > > I think perhaps mod_ruby is whacking my "cgi" object after every > > > run. Since I need the session for variable persistance, this is not > > > a good thing. > > > > > > Thanks for any help! > > > > > > -- Dan -- Daniel P. Zepeda daniel@zepeda-zone.net