sessionis not a global hash. This is a method that returns a new hash in the context of each request. How this hash is created depends on the main session store.
Let's look at 2 typical session repositories.
Encrypted cookie
This is the default session store for Rails applications. Rails serializes, then encrypts all session hashes into cookies and stores these cookies on clients (e.g., browsers). Each time a request hits the Rails application, Rails decrypts and then deserializes this session cookie into a hash. This hash is the method returned by the method session.
Redis Session Store
This session store does not ship with Rails. This is a separate stone.
Rails , ( ) ID- Redis. Rails cookie cookie . , Rails, Rails cookie, , Redis, . - , session.