Flowdock
method

session_store=

Importance_2
Ruby on Rails latest stable (v4.0.2) - 1 note - Class: ActionController::SessionManagement::ClassMethods

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

session_store=(store) public

Set the session store to be used for keeping the session data between requests. By default, sessions are stored in browser cookies (:cookie_store), but you can also specify one of the other included stores (:active_record_store, :mem_cache_store, or your own custom class.

Show source
Register or log in to add new notes.
June 18, 2008
8 thanks

Using memcached as a session store

Because of Ruby’s CGI library limitations, store cannot have any configuration options. Basically this means that you cannot easily run memcached on a different port (or with any non-default settings for that matter).

You can bypass this limitation with this ugly hack (environment.rb):

cache_params = *([memcache_servers, memcache_options].flatten)
CACHE = MemCache.new(*cache_params)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge!({ 'cache' => CACHE })

In your initializer block, just configure session_store normally:

config.session_store = :mem_cache_store

I think this should be fixed to work like cache_store= does.