Hi,
I did spend a lot of time on searching the web (including
the ruby-talk search) for ruby’s HTTP session support
before spamming the list with this…
All I found are year-old (and older) mails, like:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/8643
Does this mean that the current cgi/session is just fine
now, or people gave up the quest for the Holy Grail?
(CGI::Session used to be a little handicapped compared
to e.g. PHP’s, AFAIK.)
(I need to know it for deciding if I can start porting a web
project to Ruby, or shall I keep hacking it further in PHP.)
Thanks all so much!
Sab
(Just for the record, in case another newbie tries to find something
like this in the archive…)
Does this mean that the current cgi/session is just fine
now, or people gave up the quest for the Holy Grail?
(CGI::Session used to be a little handicapped compared
to e.g. PHP’s, AFAIK.)
I had constant problems with sessions (but that’s just usual for me,
having constant problems with things working fine for others. ).
-
Minimal sessioned .rhtml page I could come up with:
<%
require ‘cgi/session’
session = CGI::Session.new( cgi = CGI.new(‘html4’) )
begin
session['var'] = 'xxx'
···
# You WILL use sessions from mod_ruby, so don't forget this
# for closing it (ie. closing the session-file, by default).
#
# See: http://www.modruby.net/doc/faq.en.html#label:14
#
ensure
cgi.header # *NASTY* hack to flush stuff to actually make the
# session live -- needed only for creating a session.
# Any nicer way, please?? (I DO NOT want to
# clutter my "main stuff" (above) with cgi.calls, as
# I only need sessions, and conceptually, CGI has
# nothing to do with that. I want a clean page...)
session.close
end
%>
- There is a fatal bug in cgi/session.rb (class FileStore):
If you do not use or set any session variables, hitting reload
on the page will kill the script (ruby 1.6.7):
[Tue Oct 8 18:53:36 2002] [error] mod_ruby: error in ruby
/usr/lib/ruby/1.6/cgi/session.rb:123:in update': undefined method
each’ for nil (NameError)
from /usr/lib/ruby/1.6/cgi/session.rb:130:in close' from /usr/lib/ruby/1.6/cgi/session.rb:81:in
close’
from /tmp/index.rhtml.3335.0:11
from /usr/lib/ruby/1.6/apache/eruby-run.rb:112:in load' from /usr/lib/ruby/1.6/apache/eruby-run.rb:112:in
run’
from /usr/lib/ruby/1.6/apache/eruby-run.rb:78:in `handler’
from ruby:0
The problem: FileStore.update assumes @hash is never nil,
but FileStore.initialize does NOT initialize @hash if a file
for the current session-ID already exists…
Cheers,
Sz.