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_dontshuynhvanphuc
 
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...Gerryspeck
 
The Most Frequently Used Caching Headers
The Most Frequently Used Caching HeadersThe Most Frequently Used Caching Headers
The Most Frequently Used Caching HeadersHTS Hosting
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3sandeep54552
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessionsSecure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessionsSecure Code Warrior
 
Cookies authentication
Cookies authenticationCookies authentication
Cookies authenticationRsilwal123
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main TypesHTS Hosting
 
Session,Cookies and Authentication
Session,Cookies and AuthenticationSession,Cookies and Authentication
Session,Cookies and AuthenticationKnoldus Inc.
 
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 Reliability1crore projects
 
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...kalichargn70th171
 
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 schemesSahithi 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

ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
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...Nguyen Thanh Tu Collection
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryCeline George
 
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/siemaillard
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
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...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
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/
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 

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.