Session doesn't seem to store anything

I'm going to first frankly admit that this is the first web
application I'm attempting to make for the first since the depot
project in Agile Web Development with Ruby on Rails, and already, I'm
lost.

Anyway, according to my debug window I quickly made in the view files,
I can easily tell the sessions doesn't seem to hold anything. Every
time I change to another controller link, the session either
disappear, or erase itself, then fill itself up with the values the
controller said to fill.
I used the Database version of sessions
(session_store=:active_record_store) (I also don't know a thing about
MySQL. I needed the sessions to expire within a certain time limit).
To wrap up the things that could possibly be the problem:

1) Do I need to enable the session in the controller? I thought Rails
did that for me by default.
2) Do I need to create a separate column for each hash value the
session is going to store?
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...
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.
5) If none of these answers solves the problem, what may be another
solution to it?

Thanks for the help!

  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.

  1. Do I need to create a separate column for each hash value the

session is going to store?

No

  1. 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

  1. 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

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?