From: Kent Sibilev Date: 2004-10-12T08:17:32+09:00 Subject: CGI::Session::PStore#restore method Recently, I've run into the problem with CGI session resetting. I'm using CGI::Session::PStore session manager. Looking at the following method: def restore unless @hash @p.transaction do begin @hash = @p['hash'] rescue @hash = {} end end end @hash end from the lib/cgi/session/pstore.rb file made me wonder what this begin/rescue is doing there. After a little bit of investigation, it turned out that PStore#[] method never throws an exception inside the transaction scope. So this piece of code doesn't make any sense at all. I'm proposing to fix it by applying this patch: RCS file: /src/ruby/lib/cgi/session/pstore.rb,v retrieving revision 1.5 diff -u -r1.5 pstore.rb --- pstore.rb 24 Aug 2004 07:59:50 -0000 1.5 +++ pstore.rb 11 Oct 2004 23:03:43 -0000 @@ -76,11 +76,7 @@ def restore unless @hash @p.transaction do - begin - @hash = @p['hash'] - rescue - @hash = {} - end + @hash = @p['hash'] || {} end end @hash BTW, it fixes my original session reset problem nicely. Cheers, Kent.