Thursday, April 10, 2008

Merb Sessions

By default, Merb uses a cookie session store. Straight from the Merb docs:
If you have more than 4K of session data or don’t want your data to be visible to the user, pick another session store.


I have more than 4k and I don't want the data visible (most important aspect). So, since I'm using DataMapper, I'll use their session store. To do this, modify your config/init.rb as such:
Merb::Config.use do |c|
### Sets up a custom session id key, if you want to piggyback sessions of other applications
### with the cookie session store. If not specified, defaults to '_session_id'.
# c[:session_id_key] = '_session_id'

c[:session_secret_key] = '1d838e01a42847e044416d0764dc76d2b50b1045'
#c[:session_store] = 'cookie'
c[:session_store] = 'datamapper'
end


No need to manually create the sessions table, DataMapper handles this for you.

Memcache and memory session storage options are also available if you so desire.

back to Merb index

0 comments: