SlideShare a Scribd company logo
Session and cookies,get and post
MuhammedAjmalI K
mhdajmalik@gmail.com
www.facebook.com/ajuik2008
twitter.com/mhdajmalik
in.linkedin.com/in/profilename
9745020951
Session and Cookies,
Get and Post
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
Overview
• Introduction
• State Management
• Cookie
• Session
• Get
• Post
Introduction
• Web Pages developed in ASP.Net are HTTP based
and HTTP protocol is a stateless protocol.
State Management
• It is the process by which you maintain state and page
information over multiple requests for the same or
different pages.
• Two type State Management
1. Client side State Management
Data can be stored at client side.
Ex: View state, Cookies , Query strings.
2. Server side State Management
Data can be stored at Server side.
Ex: Session state.
Cookie
Introduction
• Cookies are the small text files that are stored on
client side.
• It is used for state management.
• Used to send data from one webform to another.
How to create Cookies
Step 1: Create the cookie object
HttpCookie cookie = new HttpCookie("UserDetails");
Step 2: store value into cookie
cookie["Name"] = txtName.Text;
cookie["Email"] = txtEmail.Text;
Step 3: Add the cookie to the client machine
Response.Cookies.Add(cookie);
How to read data from Cookies
Step 1: Retrieve Cookie
HttpCookie cookie = Request.Cookies["UserDetails"];
Step 2: check whether a cookie was found or not.
if (cookie != null)
{
lblName.Text = cookie["Name"];
lblEmail.Text = cookie["Email"];
}
EXAMPLE
Types Of Cookie
• Cookies can be broadly classified into 2 types
1. Non-Persistent cookies
• Temporary Cookies.
• Remain in memory until the browser is closed.
2. Persistent cookies
• permanent cookies
• Remain on the client computer, even after the browser
is closed.
How to make persistent Cookies?
• persistent cookies should have an expatriation time
defined.
– cookie.Expires = DateTime.Now.AddDays(30);
Advantages and Disadvantages
of Cookies
• Advantages
– It's very simple to use and implement.
– Browser takes care of sending the data.
• Disadvantages
– It stores data in simple text format, so it's not
secure at all.
– There is a size limit for cookies data (4KB).
Session
• Session state variables are stored on the web server
• Session state is maintained per user basis in ASP .Net
runtime.
• Default life time is 20 minute.
Storing values To Session
• Use session Object
– Session["UserName"] = txtUser.Text;
Retrieving values From Session
 Check weather session variable null or not
if (Session["UserName"] != null)
{
// Retrieving UserName from Session
lblWelcome.Text = "Welcome : " + Session["UserName"];
}
else
{ //Do Something }
Advantages and Disadvantages
of Session
• Advantages
– Stores client data separately.
– Session is secure and transparent from the user.
• Disadvantages
– Performance overhead
Get and Post
Hypertext Transfer Protocol
• Http is the most common protocol used for
communication between a web server and a client.
• The 2 most commonly used HTTP methods are
1. GET
2. POST.
GET Request
• the data being sent to your server is coded into the
URL.
POST Request
• Data will be arranged in HTTP message body.
where it is?
• <form method="get||post">
• By default Get method are used
• If the form data is large then best is use POST
• By default the form with runat="server", will
have method="post“
•
where it is? Contd..
• the first request of that page: Request is a GET
type .
• In postback: Request is a POST type
Difference between GET and POST
method
Example Programs….
if(Request.RequestType=="GET")
{
Response.Write("Request is a GET type");
}
else if(Request.RequestType=="POST")
{
Response.Write("Request is a POST type");
}
Thank You
Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course
@ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed
to make a quick, good software professional out of anybody who holds a passion for coding.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

More Related Content

PPT
Cloud computing and service models
PPT
Object Oriented Design
PPTX
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
PPT
Introduction to Google App Engine
PPTX
Cloud File System with GFS and HDFS
PPTX
Cloud computing seminar
PDF
Software Engineering : Requirement Analysis & Specification
PPT
Artificial Intelligence: The Nine Phases of the Expert System Development Lif...
Cloud computing and service models
Object Oriented Design
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Introduction to Google App Engine
Cloud File System with GFS and HDFS
Cloud computing seminar
Software Engineering : Requirement Analysis & Specification
Artificial Intelligence: The Nine Phases of the Expert System Development Lif...

What's hot (20)

PPT
Security models
PPTX
Design Model & User Interface Design in Software Engineering
PPTX
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
PPTX
Cloud security Presentation
PDF
UNIT 1 -BIG DATA ANALYTICS Full.pdf
PPT
Basic DBMS ppt
PPTX
Integration testing
PPT
Intro to Amazon S3
PPTX
Software Cost Estimation Techniques
PPTX
Cloud computing stack
PPT
Keyloggers and Spywares
PPTX
Software as a service
PPTX
Software Engineering Methodologies
PPTX
Software Crisis
PPTX
Chap 3 infrastructure as a service(iaas)
PPTX
Data partitioning
PPTX
Cloud Security
PPT
REQUIREMENT ENGINEERING
Security models
Design Model & User Interface Design in Software Engineering
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud security Presentation
UNIT 1 -BIG DATA ANALYTICS Full.pdf
Basic DBMS ppt
Integration testing
Intro to Amazon S3
Software Cost Estimation Techniques
Cloud computing stack
Keyloggers and Spywares
Software as a service
Software Engineering Methodologies
Software Crisis
Chap 3 infrastructure as a service(iaas)
Data partitioning
Cloud Security
REQUIREMENT ENGINEERING
Ad

Viewers also liked (6)

Ad

Similar to Session and cookies,get and post (20)

PPT
Session and cookies,get and post methods
PPTX
PDF
state management asp.net
PPTX
PPTX
State Management.pptx
PDF
ASP.NET-Web Programming - Sessions and Cookies
PPTX
Sessions&cookies
PPT
State management
PPTX
Get and post,session and cookie
PDF
Session and Cookies.pdf
PPTX
Cookie & Session In ASP.NET
DOC
State management in asp
PPTX
Chapter 8 part1
PDF
Asp.net state management
PPTX
State Management in ASP.NET
PPT
StateManagement in ASP.Net.ppt
PPTX
Cookie testing
PPTX
State management
PPT
Session and state management
PPTX
State management
Session and cookies,get and post methods
state management asp.net
State Management.pptx
ASP.NET-Web Programming - Sessions and Cookies
Sessions&cookies
State management
Get and post,session and cookie
Session and Cookies.pdf
Cookie & Session In ASP.NET
State management in asp
Chapter 8 part1
Asp.net state management
State Management in ASP.NET
StateManagement in ASP.Net.ppt
Cookie testing
State management
Session and state management
State management

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
PDF
Acquiring new skills what you should know
PDF
Baabtra.com programming at school
PDF
99LMS for Enterprises - LMS that you will love
PPTX
Chapter 6 database normalisation
PPTX
Chapter 5 transactions and dcl statements
PPTX
Chapter 4 functions, views, indexing
PPTX
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
PPTX
Chapter 1 introduction to sql server
PPTX
Chapter 1 introduction to sql server
Agile methodology and scrum development
Acquiring new skills what you should know
Baabtra.com programming at school
99LMS for Enterprises - LMS that you will love
Chapter 6 database normalisation
Chapter 5 transactions and dcl statements
Chapter 4 functions, views, indexing
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 1 introduction to sql server
Chapter 1 introduction to sql server

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation theory and applications.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
NewMind AI Weekly Chronicles - August'25-Week II
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
sap open course for s4hana steps from ECC to s4
Encapsulation theory and applications.pdf
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction

Session and cookies,get and post

  • 3. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 4. Overview • Introduction • State Management • Cookie • Session • Get • Post
  • 5. Introduction • Web Pages developed in ASP.Net are HTTP based and HTTP protocol is a stateless protocol.
  • 6. State Management • It is the process by which you maintain state and page information over multiple requests for the same or different pages. • Two type State Management 1. Client side State Management Data can be stored at client side. Ex: View state, Cookies , Query strings. 2. Server side State Management Data can be stored at Server side. Ex: Session state.
  • 8. Introduction • Cookies are the small text files that are stored on client side. • It is used for state management. • Used to send data from one webform to another.
  • 9. How to create Cookies Step 1: Create the cookie object HttpCookie cookie = new HttpCookie("UserDetails"); Step 2: store value into cookie cookie["Name"] = txtName.Text; cookie["Email"] = txtEmail.Text; Step 3: Add the cookie to the client machine Response.Cookies.Add(cookie);
  • 10. How to read data from Cookies Step 1: Retrieve Cookie HttpCookie cookie = Request.Cookies["UserDetails"]; Step 2: check whether a cookie was found or not. if (cookie != null) { lblName.Text = cookie["Name"]; lblEmail.Text = cookie["Email"]; } EXAMPLE
  • 11. Types Of Cookie • Cookies can be broadly classified into 2 types 1. Non-Persistent cookies • Temporary Cookies. • Remain in memory until the browser is closed. 2. Persistent cookies • permanent cookies • Remain on the client computer, even after the browser is closed.
  • 12. How to make persistent Cookies? • persistent cookies should have an expatriation time defined. – cookie.Expires = DateTime.Now.AddDays(30);
  • 13. Advantages and Disadvantages of Cookies • Advantages – It's very simple to use and implement. – Browser takes care of sending the data. • Disadvantages – It stores data in simple text format, so it's not secure at all. – There is a size limit for cookies data (4KB).
  • 14. Session • Session state variables are stored on the web server • Session state is maintained per user basis in ASP .Net runtime. • Default life time is 20 minute.
  • 15. Storing values To Session • Use session Object – Session["UserName"] = txtUser.Text;
  • 16. Retrieving values From Session  Check weather session variable null or not if (Session["UserName"] != null) { // Retrieving UserName from Session lblWelcome.Text = "Welcome : " + Session["UserName"]; } else { //Do Something }
  • 17. Advantages and Disadvantages of Session • Advantages – Stores client data separately. – Session is secure and transparent from the user. • Disadvantages – Performance overhead
  • 19. Hypertext Transfer Protocol • Http is the most common protocol used for communication between a web server and a client. • The 2 most commonly used HTTP methods are 1. GET 2. POST.
  • 20. GET Request • the data being sent to your server is coded into the URL.
  • 21. POST Request • Data will be arranged in HTTP message body.
  • 22. where it is? • <form method="get||post"> • By default Get method are used • If the form data is large then best is use POST • By default the form with runat="server", will have method="post“ •
  • 23. where it is? Contd.. • the first request of that page: Request is a GET type . • In postback: Request is a POST type
  • 24. Difference between GET and POST method
  • 25. Example Programs…. if(Request.RequestType=="GET") { Response.Write("Request is a GET type"); } else if(Request.RequestType=="POST") { Response.Write("Request is a POST type"); }
  • 27. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  • 28. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 29. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com