SlideShare a Scribd company logo
1 of 2
Download to read offline
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

Similar to Difference in session and cookie.pdf

Web application development_dos_and_donts
Web application development_dos_and_dontsWeb application development_dos_and_donts
Web application development_dos_and_donts
huynhvanphuc
 
Secure Distributed Deduplication Systems with Improved Reliability
Secure Distributed Deduplication Systems with Improved ReliabilitySecure Distributed Deduplication Systems with Improved Reliability
Secure Distributed Deduplication Systems with Improved Reliability
1crore projects
 
Srs document for identity based secure distributed data storage schemes
Srs document for identity based secure distributed data storage schemesSrs document for identity based secure distributed data storage schemes
Srs document for identity based secure distributed data storage schemes
Sahithi Naraparaju
 

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

Web application development_dos_and_donts
Web application development_dos_and_dontsWeb application development_dos_and_donts
Web application development_dos_and_donts
 
Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...
Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...
Nurturing User Trust_ Designing Privacy-Centric Websites in a Data-Driven Wor...
 
State Management.pptx
State Management.pptxState Management.pptx
State Management.pptx
 
The Most Frequently Used Caching Headers
The Most Frequently Used Caching HeadersThe Most Frequently Used Caching Headers
The Most Frequently Used Caching Headers
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessionsSecure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessions
 
Cookies
CookiesCookies
Cookies
 
Cookies authentication
Cookies authenticationCookies authentication
Cookies authentication
 
Html5 web storage
Html5 web storageHtml5 web storage
Html5 web storage
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main Types
 
Cookies & log files
Cookies & log filesCookies & log files
Cookies & log files
 
Cookies & log files
Cookies & log filesCookies & log files
Cookies & log files
 
Session,Cookies and Authentication
Session,Cookies and AuthenticationSession,Cookies and Authentication
Session,Cookies and Authentication
 
Browser Caching
Browser CachingBrowser Caching
Browser Caching
 
Secure Distributed Deduplication Systems with Improved Reliability
Secure Distributed Deduplication Systems with Improved ReliabilitySecure Distributed Deduplication Systems with Improved Reliability
Secure Distributed Deduplication Systems with Improved Reliability
 
A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...
A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...
A Comprehensive Guide to Cookie Management Using HeadSpin's Cutting-Edge Remo...
 
Srs document for identity based secure distributed data storage schemes
Srs document for identity based secure distributed data storage schemesSrs document for identity based secure distributed data storage schemes
Srs document for identity based secure distributed data storage schemes
 
Web storage
Web storage Web storage
Web storage
 
Cookie
CookieCookie
Cookie
 
Security issues in cloud database
Security  issues  in cloud   database Security  issues  in cloud   database
Security issues in cloud database
 

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
Software testing for project report .pdf
Software testing for project report .pdfSoftware testing for project report .pdf
Software testing for project report .pdf
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptxHVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 

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.