SlideShare a Scribd company logo
Difference in session and cookie
Bycodexwave.g1tech.in
Aug 14, 2023
Both sessions and cookies are used for maintaining state and storing data on the client side
in web applications, but they serve different purposes and have different characteristics.
Here’s a comparison of sessions and cookies:
Cookies:
1. Definition: Cookies are small pieces of data stored in the user’s browser. They are
sent as part of HTTP requests and responses between the client and the server.
2. Purpose: Cookies are often used to store small amounts of data, such as user
preferences, shopping cart contents, and authentication tokens.
3. Size Limit: Cookies are limited in size (typically around 4KB) due to their small
storage capacity.
4. Duration: Cookies can have an expiration date, which can be set to either persist
across multiple sessions or to expire when the browser is closed (session cookie).
5. Security: Cookies can be susceptible to security vulnerabilities like Cross-Site
Scripting (XSS) and Cross-Site Request Forgery (CSRF) attacks.
6. Access: Cookies are accessible on the client side and can be manipulated by the
user or malicious scripts.
7. Storage: Cookies are stored as key-value pairs and can be set and retrieved using
JavaScript or by HTTP headers.
8. Scoping: Cookies can be scoped to a specific domain or path, which determines
when they are sent to the server with HTTP requests.
9. Usage: Cookies are commonly used for maintaining user sessions, tracking user
behavior, and implementing features like “Remember Me” functionality.
Sessions:
1. Definition: Sessions are a way to maintain user-specific data on the server side. A
session is typically associated with a unique identifier stored in a cookie.
2. Purpose: Sessions are used to store more substantial amounts of data and sensitive
information, such as user authentication details and temporary data.
3. Size Limit: Sessions can hold larger amounts of data compared to cookies, as the
data is stored on the server side.
4. Duration: Sessions typically last as long as the user’s visit to the website. However,
sessions can be extended, and their expiration can be controlled.
5. Security: Sessions are generally more secure than cookies, as the session data
remains on the server and isn’t directly accessible to the client.
6. Access: Session data is not directly accessible by the client; it’s stored on the server
and accessed through a session identifier.
7. Storage: Session data is stored on the server’s memory or a database, depending
on the server-side technology being used.
8. Scoping: Sessions are usually scoped to a user’s entire visit to the website.
9. Usage: Sessions are used for user authentication, storing temporary data across
multiple pages, and managing user-specific state.
In summary, cookies are mainly used to store small amounts of data on the client side, while
sessions are used to maintain more extensive and sensitive data on the server side. Cookies
are accessible by the client and are sent with every HTTP request, while session data is
stored on the server and accessed through a session identifier. The choice between using
cookies and sessions depends on the specific requirements of the application and the type
of data being stored.

More Related Content

PPTX
Backend Technologies Notes ajef;asnfkndfdsa
itsmepulkitsharma
 
PPTX
Internet Cookies
anita gouda
 
PPTX
Sessions&cookies
Tirthika Bandi
 
PPTX
Authentication in Svelte using cookies.pptx
Knoldus Inc.
 
PPTX
WORKING WITH IN COOKIES JAVA SEMINAR.pptx
nandhini342004
 
PPTX
Working with in cookies java seminar.pptx
nandhini342004
 
PPTX
Cookies: HTTP state management mechanism
Jivan Nepali
 
PDF
Module-5_WTA_Managing State & jQuery
SIVAKUMAR V
 
Backend Technologies Notes ajef;asnfkndfdsa
itsmepulkitsharma
 
Internet Cookies
anita gouda
 
Sessions&cookies
Tirthika Bandi
 
Authentication in Svelte using cookies.pptx
Knoldus Inc.
 
WORKING WITH IN COOKIES JAVA SEMINAR.pptx
nandhini342004
 
Working with in cookies java seminar.pptx
nandhini342004
 
Cookies: HTTP state management mechanism
Jivan Nepali
 
Module-5_WTA_Managing State & jQuery
SIVAKUMAR V
 

Similar to Difference in session and cookie.pdf (20)

PPTX
Enterprise java unit-2_chapter-2
sandeep54552
 
PPTX
Cookies and Session
KoraStats
 
PDF
HCLT Whitepaper: Accelerated Web Content Delivery
HCL Technologies
 
PPT
Web application development_dos_and_donts
huynhvanphuc
 
PDF
Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...
Gerryspeck
 
PPTX
State Management.pptx
DrMonikaPatel2
 
PPTX
The Most Frequently Used Caching Headers
HTS Hosting
 
PPTX
Enterprise java unit-2_chapter-3
sandeep54552
 
PPTX
Web Caching Systems improve web performance by storing frequently accessed re...
Muhammmad Naveed
 
PPTX
Secure Code Warrior - Cookies and sessions
Secure Code Warrior
 
PPTX
Cookies
Mansour027
 
PPTX
Cookies authentication
Rsilwal123
 
PDF
Html5 web storage
Mindfire Solutions
 
PPTX
Caching and Its Main Types
HTS Hosting
 
PPTX
Cookies & log files
DAryll CAstelino
 
PPTX
Cookies & log files
DAryll CAstelino
 
PDF
Session,Cookies and Authentication
Knoldus Inc.
 
PDF
Browser Caching
Jaiswal Siddharth
 
PDF
Secure Distributed Deduplication Systems with Improved Reliability
1crore projects
 
PDF
A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...
kalichargn70th171
 
Enterprise java unit-2_chapter-2
sandeep54552
 
Cookies and Session
KoraStats
 
HCLT Whitepaper: Accelerated Web Content Delivery
HCL Technologies
 
Web application development_dos_and_donts
huynhvanphuc
 
Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...
Gerryspeck
 
State Management.pptx
DrMonikaPatel2
 
The Most Frequently Used Caching Headers
HTS Hosting
 
Enterprise java unit-2_chapter-3
sandeep54552
 
Web Caching Systems improve web performance by storing frequently accessed re...
Muhammmad Naveed
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior
 
Cookies
Mansour027
 
Cookies authentication
Rsilwal123
 
Html5 web storage
Mindfire Solutions
 
Caching and Its Main Types
HTS Hosting
 
Cookies & log files
DAryll CAstelino
 
Cookies & log files
DAryll CAstelino
 
Session,Cookies and Authentication
Knoldus Inc.
 
Browser Caching
Jaiswal Siddharth
 
Secure Distributed Deduplication Systems with Improved Reliability
1crore projects
 
A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...
kalichargn70th171
 
Ad

Recently uploaded (20)

PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Ad

Difference in session and cookie.pdf

  • 1. Difference in session and cookie Bycodexwave.g1tech.in Aug 14, 2023 Both sessions and cookies are used for maintaining state and storing data on the client side in web applications, but they serve different purposes and have different characteristics. Here’s a comparison of sessions and cookies: Cookies: 1. Definition: Cookies are small pieces of data stored in the user’s browser. They are sent as part of HTTP requests and responses between the client and the server. 2. Purpose: Cookies are often used to store small amounts of data, such as user preferences, shopping cart contents, and authentication tokens. 3. Size Limit: Cookies are limited in size (typically around 4KB) due to their small storage capacity. 4. Duration: Cookies can have an expiration date, which can be set to either persist across multiple sessions or to expire when the browser is closed (session cookie). 5. Security: Cookies can be susceptible to security vulnerabilities like Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF) attacks. 6. Access: Cookies are accessible on the client side and can be manipulated by the user or malicious scripts. 7. Storage: Cookies are stored as key-value pairs and can be set and retrieved using JavaScript or by HTTP headers. 8. Scoping: Cookies can be scoped to a specific domain or path, which determines when they are sent to the server with HTTP requests. 9. Usage: Cookies are commonly used for maintaining user sessions, tracking user behavior, and implementing features like “Remember Me” functionality. Sessions: 1. Definition: Sessions are a way to maintain user-specific data on the server side. A session is typically associated with a unique identifier stored in a cookie. 2. Purpose: Sessions are used to store more substantial amounts of data and sensitive information, such as user authentication details and temporary data.
  • 2. 3. Size Limit: Sessions can hold larger amounts of data compared to cookies, as the data is stored on the server side. 4. Duration: Sessions typically last as long as the user’s visit to the website. However, sessions can be extended, and their expiration can be controlled. 5. Security: Sessions are generally more secure than cookies, as the session data remains on the server and isn’t directly accessible to the client. 6. Access: Session data is not directly accessible by the client; it’s stored on the server and accessed through a session identifier. 7. Storage: Session data is stored on the server’s memory or a database, depending on the server-side technology being used. 8. Scoping: Sessions are usually scoped to a user’s entire visit to the website. 9. Usage: Sessions are used for user authentication, storing temporary data across multiple pages, and managing user-specific state. In summary, cookies are mainly used to store small amounts of data on the client side, while sessions are used to maintain more extensive and sensitive data on the server side. Cookies are accessible by the client and are sent with every HTTP request, while session data is stored on the server and accessed through a session identifier. The choice between using cookies and sessions depends on the specific requirements of the application and the type of data being stored.