ruby-on-railssession-store

Rails how to use an in Memory SessionStore


I'm looking for a way to use an in memory based session store in a Ruby on Rails application. The session contains a masterkey which can only be decrypted when the users logs in. This key should be available during the entire session.

Due to the nature of this key, the content of the session should not be stored anywhere locally. Also I don't want to transfer the content to any external application, such as memcached.

Thus is it possible to just use an in memory based session store similar to PHP or Java SE?


Solution

  • You can use a CacheStore to store session data in-memory.

    # /config/initializers/session_store.rb
    AppName::Application.config.session_store :cache_store
    

    Or you can write your own SessionStore class:

    http://guides.rubyonrails.org/configuring.html#rails-general-configuration