I’m using mod_ruby, eruby and CGI::Session in an application. It seems
that the cookie is never being sent, and I have no idea why. Here’s a
simple rhtml file illustrating the problem:
% require ‘cgi’
% require ‘cgi/session’
% require ‘cgi/session/pstore’
% cgi=CGI.new()
% sess=CGI::Session.new(cgi, ‘database_manager’ =>
CGI::Session::PStore, ‘session_key’ => ‘hello_session’)
<% sess[‘visits’] ||= 0 %>
<%= sess.session_id %>
<%= sess[‘visits’] %> visits
<% sess[‘visits’] += 1
sess.close%>
Each time this is loaded, no cookie is set, so no session ID is sent
back to the page on reload and a new session is started each time.
This behavior does not match any of the documentation I’ve been able
to find, but it does match what’s described in
http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/84a1bddd046a9b66/d6d7e7340a5a3bb1
The above poster solved his problem by passing around the session ID
as a query parameter, but that seems to miss the point of using
CGI::Session. Am I missing something obvious here?