There is no way you can skip cookies if you are a developer. A cookie is today as important in internet as any language. Cookies has made our way simpler and better, both for the developer and the user. So in this chapter we will focus on.
What is a cookie?
Cookie in simpler terms means just the textual information about some website. When you visit a particular website, some information is saved in your local system so that when you visit the same website again, this website is able to recognize you and show you the results according to your preferences. Cookies have been long used in the internet history and have developed in a magnificent way.
When you visit a website you actually requests the web page from the server. For a server, every request is a unique request. So if you visit hundred times, the server will consider each and every request unique. Since the intensity of requests that arrive at a server is high, it is obvious and logical not to store every user’s information to the server. Maybe you never visit again and the same information will be redundant. So, to uniquely remember you, the server sends the cookies along with the response which is saved in your local machine. Now the next time you hit the same server, you will get a response according to you as the server will recognize you.
This cookie is unique to every server (some exceptions exist today because of advertisements). So you might have many cookies in your system but a server will recognize it’s own cookie and can analyse it for you. How this evolved over time and used today is discussed in the next section.
Cookies developed in the initial days because developers needed some information about the client to make their experience better. Let say you visit a website which is not in your local language (let’s say English). You choose the English option in the language section of the website. Now if you visit the same website 5 times a day, you might have to change the language 5 times. Therefore, this information is saved as a cookie in your system. So the next time you send the request, the server will know that you want to see the website in english. This is where cookies play a vital role. But this is a very minute example of the scale cookies are used today.
Advancement of cookies:
The concept of cookies was developed for creating a better experience by saving little information as texts on the client’s machine. But as the concept became more and more demanding and successful, the usage of cookies increased many folds. Today, cookies are used from what you searched to even what you saved in your cart. Cookies are used today at an extreme level saving your information about various websites. Knowing this, it is obvious that the size of the information has increased. So developers have recognized that all the information cannot be saved in the client’s machine as it will increase the cookie size which is sent with requests and also will load the client’s machine. Therefore cookies are now saved in a different way.
Now, if you visit a website, the website provide you with a cookie id which is uniquely recognizable by the server. This id is then linked to the database of the company where all your information is saved and then fetched from the database. This way cookies can be managed more efficiently and more securely.
Security threats related to Cookies:
Cookies as you must have come to know till now, saves your information to your machine. This information is highly personal to you and should only be retrieved by the server which saved it. Does it possess any security threats? Fortunately no. The following things should be kept in mind:
- A cookie cannot be used by any other server as the id saved in your cookie is directly mapped to the website’s database.
- A cookie can never be used to access any information saved in your system, browser or hard disk.
- A cookie cannot be used to deliver viruses or any other threats.
- A cookie but can be used by a third website (with permissions of course) to access the information and/or your preferences to use them for their and your benefit. To understand it a bit more, we should understand the types of cookies.
Refer for – How cookies are used in a website?
- How cookies are used in a website?
- If we delete cookies of a site, we can still logged in without logging again
- How slow HTTP can knock down a server?
- What are the differences between HTTP, FTP, and SMTP?
- Session Management in HTTP
- What is web socket and how it is different from the HTTP?
- Why HTTP is not Secure ?
- How To Launch A Startup - 8 Step Process!
- AWS Certification Path - Levels, Exam, Cost
- Top 10 Cloud Computing Research Topics in 2020
- How to Choose a Programming Language For a Project?
- Design Twitter - A System Design Interview Question
- How to Become a Cyber Security Engineer?
- Difference between Full stack developer and Software developer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.