Session was a cookie designed to be erased when the browser was closed and was a method for exchanging it: Rails Tutorial Note-What is a Rails Session?

Session was a cookie designed to be erased when the browser was closed and was a method for exchanging it: Rails Tutorial Note-What is a Rails Session?

Abstract: What is a Rails Session?

I noticed from the time of Progate that I was next to session

As you progress through the Rails tutorial

Something like a variable called a session Login maintenance mechanism using cookies to supplement it I had a feeling of being moody, but in reality

Both

--Mechanism for making HTML stateful --Both are stored in cookies by default

However

--session was implemented by Rails, but login maintenance by cookie was implemented later. --session has a time limit (default?), While the latter is permanent (intentionally designed)

I used a time-limited cookie A mechanism for making HTML stateful called a session ** The developer did not intend ** to implement the session method in Rail.

Note: What is a Rails Session?

HTML is stateless by nature and has no continuity persistence

Stateless in an instant DIVE INTO CODE | Learn about login information retention

Session is a mechanism for making stateless HTML stateful

Is it a ** mechanism like Cookie **? I did it in Chapter 8 of the Rails tutorial

If you think In the first place, Rails stores session in cookie by default.

I checked it with Chrome's developer tools I have a _sample_app_session that seems to be for the Rails tutorial sample_app

Furthermore, the expiration date is ** "at the end of the browser session" **. This was the reason for the ephemeral feel imprinted in the Rails tutorial.

What is session in Rails?

session is a method, not a variable Since it was automatically generated by the process of rails new sample_app

I understood that ** it was used as a matter of course **

For example, if Rails new hoge is installed with Rails installed, a Rails application will be created, and if rails g controller sessions in the hoge directory will generate SessionsController that inherits ApplicationController, it will be written as session [: hoge] from the beginning. You can use session. Complete understanding of Rails session-Qiita

I used this as a reference to understand the reality of Rails sessions a little easier. [Rails] How to use Session --Qiita

Recommended Posts

Session was a cookie designed to be erased when the browser was closed and was a method for exchanging it: Rails Tutorial Note-What is a Rails Session?
If it is Ruby, it is efficient to make it a method and stock the processing.
When I wanted to create a method for Premium Friday, it was already in the Java 8 standard API
[Rails] What to do when the view collapses when a message is displayed with the errors method
Is it easy for the user to use when implementing general-purpose functions? Let's be aware of
Rails Tutorial Chapter 14 was completed, and it took a total of 155.5 hours.
When you want Rails to disable a session for a specific controller only
When I defined a session scope bean in Spring Boot, it behaved strangely and needed to be adjusted.
When reassigning to an argument in a Ruby method and then calling `super` → The reassigned one is used
Find a value that is convenient to have a method and make it a ValueObject
When importing CSV with Rails, it was really easy to use the nkf command