3

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?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109

2 Answers2

1

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?

Community
  • 1
  • 1
Vince V.
  • 3,115
  • 3
  • 30
  • 45
1

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/

Rokibul Hasan
  • 4,078
  • 2
  • 19
  • 30