Re: Session doesn''t seem to store anything

Taro
Fri, 03 Aug 2007 14:59:59 -0000

OK, I''ll try that.  Many thanks!  Out of curiosity, what
does :session_key do?  Is it something like a security thing for
sessions or something?

On Aug 3, 10:19 am, Peter De Berdt
<peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org>
wrote:
> On 03 Aug 2007, at 15:38, Taro wrote:
>
> > 1) Do I need to enable the session in the controller?  I thought Rails
> > did that for me by default.
>
> Just comment out the :session_key line in the application controller
> and see if that solves it.
>
> > 2) Do I need to create a separate column for each hash value the
> > session is going to store?
>
> No
>
> > 3) Did I initialize the session wrong?  How can I check?  I first
> > typed in the command line, "rake db:sessions:create", then
"rake
> > db:migrate", so the table should be there...
>
> Make sure you set the session store to active_record_store
>
> > 4) Where can I learn a little bit about MySQL?  I''m a little
> > intimidated by their homepage, yet I need to find a way to create a
> > sweeper for the session table.
>
> The easiest way to do it, is pick out a method that''s going to be
> called on regular occasions (such as the login method) and do the
> session cleanup there (as long as you don''t have thousands of
> concurrent requests, the cleanup won''t slow down the site):
>
> Put this in environment.rb (at the bottom)
> # Method for cleaning up stale sessions
> class SessionCleanup
>    def self.cleanup
>      CGI::Session::ActiveRecordStore::Session.destroy_all(
>        [''updated_at < ?'', 8.hours.ago]
>      )
>    end
> end
>
> Then in your login method:
>
> def login
>     SessionCleanup.cleanup
>     ...
> end
>
> Best regards
>
> Peter De Berdt