Search code examples
ruby-on-railsruby-on-rails-3sessioncontrollers

Does Rails create a new session when different controllers are called?


Say I have an app with multiple controllers .

UserController

EventsController

Does Rails create different sessions when I first request for User#show method and then go on to call Events#show method ?

Or is the same session created in the first instance valid even during the second call.


Solution

  • No, rails does not create different sessions for each request (unless expired or deleted). In fact, that would invalidate the whole point of sessions, which is to share state between requests.