[RUBY] Understand in 3 minutes! A very rough explanation of the difference between session and cookie

スクリーンショット 2020-11-04 0.35.30.png

Common role of session and cookie

First of all, sessions and cookies have a common role of storing information! This is the cause of my disappointment ...

What is a cookie?

First of all, a cookie is a file that you have in your browser. There are various types such as chrome and firefox.

For example, login information is also saved in the browser using cookies. Advertising is easy to understand afterwards! !!

スクリーンショット 2020-11-04 0.35.30.png

I've been reading various Qiita articles about changing jobs recently, so this kind of advertisement is displayed. It uses features such as third-party cookies to display suitable ads from that person's cookie information!

If you feel that your browser is heavy, you may want to review the cookie cache as well, as it can cause chrome to slow down if the cookie cache accumulates too much! https://www.webhack.jp/web-service/google-chrome%E3%81%8C%E9%81%85%E3%81%84%EF%BC%81%E9%87%8D%E3%81%84%EF%BC%81%E5%8E%9F%E5%9B%A0%E3%81%A8%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95-%E9%AB%98%E9%80%9F%E5%8C%96%E3%81%AE%E8%A3%8F%E6%8A%80/#i-3

What is a session

Session stores information on the server much more than cookies store information in the browser! Often, login information etc. is saved on the server! Keep information on the server and share it across multiple pages!

For example, if you log in as Mr. A, you can edit Mr. A's data when you access the user edit page, right? This is because the session remembers your login information!

After that, even if the products added to the cart are on other pages, such as shopping sites, the record remains. This also uses session. However, basically session loses its information when the browser is closed.

Compared to cookies, it is more secure because it stores information in the server information.

Summary

・ Storage location cookie → browser session → server

・ Storage capacity cookie → There is an upper limit (it also causes the browser to become heavy) session → almost no upper limit

・ Security cookie → dangerous Less dangerous than session → cookie

Recommended Posts

Understand in 3 minutes! A very rough explanation of the difference between session and cookie
Understand the difference between each_with_index and each.with_index
[Rails] Difference in behavior between delegate and has_many-through in the case of one-to-one-to-many
Get a rough idea of the differences between protocols, classes and structs!
Understand the difference between int and Integer and BigInteger in java and float and double
[Java] Understand the difference between List and Set
[iOS] Understand the difference between frame and bounds
Understand the difference between abstract classes and interfaces!
About the difference between classes and instances in Ruby
Understand the characteristics of Scala in 5 minutes (Introduction to Scala)
Calculate the difference between numbers in a Ruby array
Is there a performance difference between Oracle JDK and OpenJDK at the end of 2017?
A quick explanation of the five types of static in Java
About the difference between "(double quotation)" and "single quotation" in Ruby
[Ruby] About the difference between 2 dots and 3 dots of range object.
What is the difference between the responsibilities of the domain layer and the application layer in the onion architecture [DDD]
[Ruby] Difference between symbol variables and character string variables. About the difference between [: a] and ['a'].
Output the difference between each field of two objects in Java
Rough difference between RSpec and minitest
What is the difference between a web server and an application server?
Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display
Easy to understand the difference between Ruby instance method and class method.
The difference between puts and print in Ruby is not just the presence or absence of line breaks
The story of forgetting to close a file in Java and failing
A note on the differences between interfaces and abstract classes in Java
Difference between final and Immutable in Java
Difference between pop () and peek () in stack
About the difference between irb and pry
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between addPanel and presentModally of FloatingPanel
Find the difference from a multiple of 10
Difference between int and Integer in Java
Let's explain the difference between an interpreter and a compiler using a Venn diagram
[Ruby] Difference between methods with and without self in the class. About class methods and instance methods.
Be absolutely careful when putting the result of and / or in a variable!
[Rails / ActiveRecord] About the difference between create and create!
Measure the size of a folder in Java
Difference between next () and nextLine () in Java Scanner
What is the difference between SimpleDateFormat and DateTimeFormatter? ??
[Java] Understand in 10 minutes! Associative array and HashMap
Difference between member and collection of rails routes.rb
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
Count the number of occurrences of a string in Ruby
[Ruby] I thought about the difference between each_with_index and each.with_index
[Rails] I learned about the difference between resources and resources
What is the difference between System Spec and Feature Spec?
Regarding the difference between the three Timeouts in Java's HttpClient
Difference between new and create in Rais action controller
Review the multilingual support (i18n) of the ios app in 3 minutes
A rough explanation of how Java-based web applications work
[Java] Difference between static final and final in member variables
[Rails] What is the difference between redirect and render?
Compare the difference between dockerfile before and after docker-slim
[JAVA] What is the difference between interface and abstract? ?? ??
Verification of the relationship between Docker images and containers
Java classes and instances to understand in the figure
What is the difference between skip and pending? [RSpec]
[Rails] I investigated the difference between redirect_to and render.
What is the difference between Java EE and Jakarta EE?
[Swift] UITextField taught me the difference between nil and ""