Showing posts with label sessions. Show all posts
Showing posts with label sessions. Show all posts

Wednesday, 9 January 2008

Enabling Sessions in MERB

Sessions are disabled by default in MERB (because it makes the performance numbers look great! ;) ). To enable sessions, just set the variable :session_store: in merb.yml to one of activerecord, sequel, datamapper, memory, cookie or mem_cache.

Because I want to use memory for my development sessions and mem_cache for my production environment, I set up config/environments/development.yml and put in:

:session_store: memory
:memory_session_ttl: 3600


and config/environments/production.yml and put in:

:session_store: mem_cache


If you're using memcached with MERB, you need to put


require 'memcache'
CACHE = MemCache.new('127.0.0.1:11211', { :namespace => 'my_app' })


in your merb_init.rb (http://merb.rubyforge.org/classes/Merb/MemCacheSession.html)