Is a session a method or a hash in Rails? A little confused

A very simple question arises. I do the Michael Hartle Rail Guide and he talks about using the session method:

User login is simple using the session method defined by Rails ... We can process the session as if it were a hash and assign it the following:

session[:user_id] = user.id

It says that you can view the session as if it were a hash, but I'm confused because it is called a session method, so what is actually called? I assume that by inserting into the session hash there is a session function that looks into the hash to see if there is anything present? I'm not sure how this works.

+4
source share
2

, , () , Hash, [] []=. ActionDispatch::Request::Session.

+2

Session :

( cookie, Rails URL-, ).

, , - Rails, , ().

cookie Ruby, :

session[:your_hash] = "TEST"

(, user_id ) .


, Rails HTTP, .

; , .. , .

, Rails "" - , . , / .., "" .

user_id - , , id, -.

+2

Source: https://habr.com/ru/post/1612856/


All Articles