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

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
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessionsSukrit Gupta
 

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

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
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 

Recently uploaded

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

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.