Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Cookies | Network Security
Next article icon

Cookies | Network Security

Last Updated : 12 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Cookies are termed as certain messages when a web server transmits any messages to a web browser so that the web server can monitor the user's activity on a particular website. It is a small piece of information that a website stores on your computer, and uses it at the time of your iteration on that website. When you revisit the website your browser sends information back to the site.

The main aim of cookies is to identify users and perhaps prepare customized Web pages for them. Cookies do not act maliciously on computer systems i.e., they are only text files that can be deleted at any time, they are not plugins, nor do they program. In this article, we will learn about the cookies on websites, why cookies are used, and what are the different types of cookies.

What are Cookies on Websites?

Cookies can not read your hard drive to find out information about you, however, any personal information that you give to a website, including credit or debit card information, will most likely be stored in a cookie unless you have turned off the cookies a threat to privacy. The cookie will only contain information that you freely provide to a Website. Do not give your credential information on non-trusted websites or web pages. It may lose your data and information.

The web browser stores the message/information in a text file, and is the message/information then sent back to the server each time the browser requests a page from the server. The name cookie is derived from UNIX objects called magic cookies. These tokens are attached to a user or program and switch depending on the areas entered by the user or program. Cookies cannot be used to spread viruses, and they cannot access your hard drive.

What are Cookies Used For?

  • Session Management: Cookies store things like items in your shopping cart or your language preference, so you don’t have to re-enter this information each time you visit. Cookies let websites allow users and recollect their individual login information and preferences.
  • Tracking: Advertisers use cookies to track your browsing habits and show you ads that are relevant to you based on the sites you visit. E-Commerce sites also use cookies to track items users had previously viewed allowing the sites to suggest other goods in which you are interested.
  • Personalization: They allow websites to show you content that matches your interests, like suggesting videos or products similar to what you’ve viewed before. It is customized advertising which is the main way cookies are used to personalize your sessions.
  • Keeping You Logged In: Cookies remember your login details, so you don’t need to enter your username and password every time you visit a website.
Cookies-in-Network-Security
Cookies in network security

Where are Cookies Stored?

Cookies are stored on your device in special folders or files within your web browser. Here’s where they can typically be found:

  • On Your Computer or Device: Cookies are stored as small text files on your hard drive or in your device’s storage.
  • In Your Web Browser: Each browser (like Chrome, Firefox, or Safari) has its own way of storing cookies. They keep cookies in a specific location within the browser's data storage.
  • In the Browser’s Data Folder: For instance, in Chrome, cookies are kept in the “Cookies” file located in the browser's profile directory, while Firefox uses a database file called cookies.sqlite.
  • In the Browser's Settings: You can usually view and manage stored cookies through your browser's settings or preferences under privacy or security sections.

To access cookies in chrome browser, you need to follow these steps:

  • Chrome: Settings > Privacy and Security > Cookies and other site data > See all site data and permissions.

Parameter for Cookies

Cookies have six parameters that can be passed to them :

  1. Name of the cookie - Determines the name of the cookie.
  2. Value of the cookie - Determines the value of the cookie.
  3. The expiration date of the cookie - determines how long the cookie will remain active in your browser.
  4. Valid path for the cookie - This sets the URL path in which the cookie is valid. Web pages or websites outside the path of the cookie cannot use the cookie.
  5. Valid domain for the cookie - This takes the path parameter one step further. This makes the cookie accessible to pages on any of the servers when a site uses multiple servers in a domain.
  6. Need for a secure connection - It specifies that a cookie can only be used under a secure server condition, such as a site using SSL.

What are the Different Types of Cookies?

Here are the 5 important types of cookies with a bit more detail:

1. Session Cookies:

  • These are the temporary cookies that help websites remember your actions during a single visit, such as items in your shopping cart or form inputs.
  • They are deleted when you close your browser, so they don't store information after you leave the site.

2. Persistent Cookies:

  • Cookies that stay on your device for a set period or until you manually delete them. They remember your preferences, such as login details or language settings.
  • They allow websites to recognize you and recall your settings on future visits, making your experience smoother.

3. First-Party Cookies:

  • Created and stored by the website you're currently visiting. They store information like login status, site preferences, and items in your cart.
  • They improve the website’s functionality by keeping track of your interactions on that site alone.

4. Third-Party Cookies:

  • Set by different websites (third parties), usually advertisers, not by the site you’re currently on. They track your browsing habits across various sites to show you targeted ads.
  • They help advertisers display ads based on your browsing history, but can also be used for analytics and social media plugins.

5. Secure Cookies:

  • Cookies that are only transmitted over encrypted connections (HTTPS), ensuring that sensitive information like login credentials are safe during transfer.
  • They enhance security by protecting the cookie data from being intercepted by unauthorized parties during online transactions.

Conclusion

Cookies are small data files stored on your device by websites to remember information about you. They make your online experience smoother by keeping track of things like login details, preferences, and actions on a site. While cookies help personalize your browsing and keep you logged in, they can also be used to show you targeted ads and track your activity across different sites. Managing cookies can improve your privacy and control over your online interactions.


Next Article
Cookies | Network Security

N

nitishkumarpatel191
Improve
Article Tags :
  • Computer Networks
  • Network-security

Similar Reads

    Protection Methods for Network Security
    In today’s generation, communication and sharing information are the key to success. Here, the network means the interconnection of two or more computers. This networking is very beneficial in many fields like exchanging information, sharing resources such as printers and scanners, sharing software,
    2 min read
    HTTP headers | Set-Cookie
    The HTTP header Set-Cookie is a response header and used to send cookies from the server to the user agent. So the user agent can send them back to the server later so the server can detect the user. Syntax: Set-Cookie: <cookie-name>=<cookie-value> | Expires=<date> | Max-Age=<no
    2 min read
    HTTP headers | Set-Cookie2
    The HTTP Set-cookie2 is response type header and it is obsoleted. It is a provider of the mechanism to serve and retrieve state information from the client to the server. The usage of this command is usually replaced by the set cookie instead of the set cookie2. The usage of this command cookie2 is
    2 min read
    Top 10 Network Security Best Practices in 2025
    Are your network defenses strong enough to withstand today's advanced cyber threats? What measures have you implemented to protect your organization's data? As cyberattacks become more frequent, sophisticated, and devastating, these questions are more critical than ever. Organizations face a constan
    8 min read
    What are Internet Cookies?
    Cookies enable websites to remember you and how you like things done, remember your login details, or what items you have stashed in your shopping cart. We've all seen, at some point in time, pop-up messages on websites asking you to choose to allow cookies on your device. But what are these cookies
    15+ min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences