[Rails] Session in ActiveRecordStore

Jeremy Kemper
2006-05-17T19:14:46Z

On May 17, 2006, at 11:47 AM, Warren Seltzer wrote:
> Anyway, I''ve tried both, and in both cases it generates new
> sessions all too quickly, so that no page sees the same session as
> the page before it.  The sessions appear in the database.  But as
> far as rails is concerned it only reads blank virginal sessions
> over and over.  So no flash appears either.   All it has to do is
> redirect to a different page and the session_id in the log is
> different, so the session is new and "blank".

Sorry if it''s a no-brainer, but you have cookies enabled?

You can check for it in your controllers:

   class ApplicationController < ActionController::Base
     protected
       # Before filter: redirect to no cookies page if _session_id
cookie is missing.
       def must_have_session_cookie
         if cookies[''_session_id'']
           true
         else
           redirect_to :controller => ''about'', :action
=> ''cookies''
           false
         end
       end
   end

   class FooController < ApplicationController
     before_filter :must_have_session_cookie, :except =>
[:login, :signup]
   end

Best,
jeremy