Cookies are encrypted by default in Rails 4
In Rails 4, CookieStore cookies are encrypted and signed by default:
If you only have secret_token , your cookies will be signed but not encrypted. This means that the user cannot change his user_id without knowing your app secret key, but can easily read their user_id . This was the default for Rails 3 applications.
If you have secret_key_base set, your cookies will be encrypted. This is a step further than signed cookies in that encrypted cookies cannot be changed or read by users. This starts with Rails 4 by default.
If you have both secret_token and secret_key_base , your cookies will be encrypted and the signed cookies created by Rails 3 will be transparently read and encrypted to ensure a smooth update path.
Active recording session store deprecated in Rails 4
This answer is now deprecated in relation to Rails 4. Active record The session log is deprecated and removed from Rails, so the following generators will no longer work:
This has been indicated in this answer . The reason the active Session Storage entry was deprecated because reading / writing to the database is not good when you have a large number of users accessing your application, as outlined in this blog post :
... one important issue with Active Record session storage is that it is not scalable. This creates an unnecessary load on your database. As soon as your application receives a large amount of traffic, the session database table is continuously bombarded by read / write operations.
With Rails 4, the Active Record session store is removed from the kernel and is now deprecated.
If you still want to use the Active Record session store, it is still available as a gem .
Recommendations for working with current rails
For more up-to-date best practices for Ruby on Rails sessions, I suggest you check out the latest versions of the Ruby on Rails Security Guide .
user456814 Apr 18 '14 at 22:45 2014-04-18 22:45
source share