Using active record (database) for session information storage

If you have a problem about the cookie size (4KB) in your application, you may use database storage help. With this manipulation your app will keep an id in cookie and store other information in “sessions” table in DB and it will call the data from table by the id that is kept in cookie.

First: Execute following (it will create the table structure that is ready to be migrated)

rake db:sessions:create

Second: It’ll create the table

rake db:migrate

Third: inside the config/initializers/session_store.rb add following

MyApp::Application.config.session_store :active_record_store

That s all folks…