Reputation: 51
I want to know how sessions work in Ruby on Rails.
I already now that I can save a session with session[:user_id] = @user.id
and retrieve it with session[:user_id]
.
Thus, does Rails save the session to cookie store, cache store, or database store?
Upvotes: 3
Views: 2344
Reputation: 4156
When you request a webpage, the server can set a cookie when it responds back. You can read this article, it will clear you concept about sessions. http://www.justinweiss.com/blog/2015/03/17/how-rails-sessions-work/
Upvotes: 1
Reputation: 3143
Sessions are kept serverside. It's saved on the webserver itself. This can be in a file/memory/database. The ID of that session is saved in a cookie on the user his browser to associate the user with the correct session.
More information can be found here:
What are sessions? How do they work?
Upvotes: 1