diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-21 23:41:15 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-21 23:41:15 -0700 |
commit | 3c3129993ad40768577371a0f389a54ff6db7f68 (patch) | |
tree | e287eb71e86fab19ee9ecca913461d10fa612c41 /railties/guides/source/action_controller_overview.textile | |
parent | d8b09f3866defcd1bc97717fcc1bbfe9f643bd8c (diff) | |
parent | 2b04c2f66e3cf5abbbf118eaa1e692b9e1380e4e (diff) | |
download | rails-3c3129993ad40768577371a0f389a54ff6db7f68.tar.gz rails-3c3129993ad40768577371a0f389a54ff6db7f68.tar.bz2 rails-3c3129993ad40768577371a0f389a54ff6db7f68.zip |
Merge pull request #3396 from bdurand/session_cache_store
Add ActionDispatch::Session::CacheStore as a generic way of storing sessions in a cache
Diffstat (limited to 'railties/guides/source/action_controller_overview.textile')
-rw-r--r-- | railties/guides/source/action_controller_overview.textile | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index 5019d49686..b34c223b31 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -166,10 +166,10 @@ h3. Session Your application has a session for each user in which you can store small amounts of data that will be persisted between requests. The session is only available in the controller and the view and can use one of a number of different storage mechanisms: -* CookieStore - Stores everything on the client. -* DRbStore - Stores the data on a DRb server. -* MemCacheStore - Stores the data in a memcache. -* ActiveRecordStore - Stores the data in a database using Active Record. +* ActionDispatch::Session::CookieStore - Stores everything on the client. +* ActiveRecord::SessionStore - Stores the data in a database using Active Record. +* ActionDispatch::Session::CacheStore - Stores the data in the Rails cache. +* ActionDispatch::Session::MemCacheStore - Stores the data in a memcached cluster (this is a legacy implementation; consider using CacheStore instead). All session stores use a cookie to store a unique ID for each session (you must use a cookie, Rails will not allow you to pass the session ID in the URL as this is less secure). @@ -177,6 +177,8 @@ For most stores this ID is used to look up the session data on the server, e.g. The CookieStore can store around 4kB of data -- much less than the others -- but this is usually enough. Storing large amounts of data in the session is discouraged no matter which session store your application uses. You should especially avoid storing complex objects (anything other than basic Ruby objects, the most common example being model instances) in the session, as the server might not be able to reassemble them between requests, which will result in an error. +If your user sessions don't store critical data or don't need to be around for long periods (for instance if you just use the flash for messaging), you can consider using ActionDispatch::Session::CacheStore. This will store sessions using the cache implementation you have configured for your application. The advantage of this is that you can use your existing cache infrastructure for storing sessions without requiring any additional setup or administration. The downside, of course, is that the sessions will be ephemeral and could disappear at any time. + Read more about session storage in the "Security Guide":security.html. If you need a different session storage mechanism, you can change it in the +config/initializers/session_store.rb+ file: |