Session and cookies,get and post

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
1 de 29

Recomendados

Apache Iceberg: An Architectural Look Under the Covers por
Apache Iceberg: An Architectural Look Under the CoversApache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the CoversScyllaDB
1.4K vistas24 diapositivas
Informatica Powercenter Architecture por
Informatica Powercenter ArchitectureInformatica Powercenter Architecture
Informatica Powercenter ArchitectureBigClasses Com
4.7K vistas8 diapositivas
Percona xtrabackup - MySQL Meetup @ Mumbai por
Percona xtrabackup - MySQL Meetup @ MumbaiPercona xtrabackup - MySQL Meetup @ Mumbai
Percona xtrabackup - MySQL Meetup @ MumbaiNilnandan Joshi
3.9K vistas53 diapositivas
Informatica Power Center 7.1 por
Informatica Power Center 7.1Informatica Power Center 7.1
Informatica Power Center 7.1ganblues
13.1K vistas194 diapositivas
Physical database design(database) por
Physical database design(database)Physical database design(database)
Physical database design(database)welcometofacebook
15.6K vistas33 diapositivas
Big Data Trends por
Big Data TrendsBig Data Trends
Big Data TrendsDavid Feinleib
88.3K vistas52 diapositivas

Más contenido relacionado

La actualidad más candente

Introduction to database por
Introduction to databaseIntroduction to database
Introduction to databasePradnya Saval
286 vistas25 diapositivas
How to Analyze and Tune MySQL Queries for Better Performance por
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
1.7K vistas138 diapositivas
Sql Server Basics por
Sql Server BasicsSql Server Basics
Sql Server Basicsrainynovember12
25.1K vistas33 diapositivas
Normalization in databases por
Normalization in databasesNormalization in databases
Normalization in databasesbaabtra.com - No. 1 supplier of quality freshers
5.6K vistas27 diapositivas
Introduction to Data Engineering por
Introduction to Data EngineeringIntroduction to Data Engineering
Introduction to Data EngineeringHadi Fadlallah
1.1K vistas40 diapositivas
Oracle architecture ppt por
Oracle architecture pptOracle architecture ppt
Oracle architecture pptDeepak Shetty
24K vistas34 diapositivas

La actualidad más candente(20)

Introduction to database por Pradnya Saval
Introduction to databaseIntroduction to database
Introduction to database
Pradnya Saval286 vistas
How to Analyze and Tune MySQL Queries for Better Performance por oysteing
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
oysteing1.7K vistas
Introduction to Data Engineering por Hadi Fadlallah
Introduction to Data EngineeringIntroduction to Data Engineering
Introduction to Data Engineering
Hadi Fadlallah1.1K vistas
Oracle architecture ppt por Deepak Shetty
Oracle architecture pptOracle architecture ppt
Oracle architecture ppt
Deepak Shetty24K vistas
Apache Iceberg Presentation for the St. Louis Big Data IDEA por Adam Doyle
Apache Iceberg Presentation for the St. Louis Big Data IDEAApache Iceberg Presentation for the St. Louis Big Data IDEA
Apache Iceberg Presentation for the St. Louis Big Data IDEA
Adam Doyle610 vistas
MySQL Architecture and Engine por Abdul Manaf
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
Abdul Manaf2.1K vistas
Top 10 Mistakes When Migrating From Oracle to PostgreSQL por Jim Mlodgenski
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Jim Mlodgenski3.7K vistas
Introduction to snowflake por Sunil Gurav
Introduction to snowflakeIntroduction to snowflake
Introduction to snowflake
Sunil Gurav11.6K vistas
Snowflake for Data Engineering por Harald Erb
Snowflake for Data EngineeringSnowflake for Data Engineering
Snowflake for Data Engineering
Harald Erb812 vistas
Designing Data-Intensive Applications_ The Big Ideas Behind Reliable, Scalabl... por SindhuVasireddy1
Designing Data-Intensive Applications_ The Big Ideas Behind Reliable, Scalabl...Designing Data-Intensive Applications_ The Big Ideas Behind Reliable, Scalabl...
Designing Data-Intensive Applications_ The Big Ideas Behind Reliable, Scalabl...
SindhuVasireddy1225 vistas
Introduction to Data Engineer and Data Pipeline at Credit OK por Kriangkrai Chaonithi
Introduction to Data Engineer and Data Pipeline at Credit OKIntroduction to Data Engineer and Data Pipeline at Credit OK
Introduction to Data Engineer and Data Pipeline at Credit OK
Understanding MySQL Performance through Benchmarking por Laine Campbell
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through Benchmarking
Laine Campbell12.9K vistas
PostgreSQL Database Slides por metsarin
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin5.4K vistas

Destacado

Stored procedures with cursor por
Stored procedures with cursorStored procedures with cursor
Stored procedures with cursorbaabtra.com - No. 1 supplier of quality freshers
628 vistas18 diapositivas
Application of MoMSME- Support for Entrepreneurial and Management Development... por
Application of MoMSME- Support for Entrepreneurial and Management Development...Application of MoMSME- Support for Entrepreneurial and Management Development...
Application of MoMSME- Support for Entrepreneurial and Management Development...baabtra.com - No. 1 supplier of quality freshers
694 vistas3 diapositivas
Pre processor directives in c por
Pre processor directives in cPre processor directives in c
Pre processor directives in cbaabtra.com - No. 1 supplier of quality freshers
3.6K vistas28 diapositivas

Similar a Session and cookies,get and post

Session and cookies,get and post methods por
Session and cookies,get and post methodsSession and cookies,get and post methods
Session and cookies,get and post methodsbaabtra.com - No. 1 supplier of quality freshers
1.5K vistas24 diapositivas
C# cookieless session id and application state por
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application stateMalav Patel
399 vistas16 diapositivas
State Management.pptx por
State Management.pptxState Management.pptx
State Management.pptxDrMonikaPatel2
4 vistas31 diapositivas
State management in ASP .NET por
State  management in ASP .NETState  management in ASP .NET
State management in ASP .NETbaabtra.com - No. 1 supplier of quality freshers
5.6K vistas25 diapositivas
State management in ASP.net por
State  management in ASP.netState  management in ASP.net
State management in ASP.netbaabtra.com - No. 1 supplier of quality freshers
2.6K vistas25 diapositivas
Web Performance Optimization (WPO) por
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Betclic Everest Group Tech Team
2.3K vistas26 diapositivas

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

C# cookieless session id and application state por Malav Patel
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application state
Malav Patel399 vistas
Session and Cookies.pdf por HamnaGhani1
Session and Cookies.pdfSession and Cookies.pdf
Session and Cookies.pdf
HamnaGhani12 vistas
Enterprise java unit-2_chapter-3 por sandeep54552
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
sandeep54552561 vistas
USG Rock Eagle 2017 - PWP at 1000 Days por Eric Sembrat
USG Rock Eagle 2017 - PWP at 1000 DaysUSG Rock Eagle 2017 - PWP at 1000 Days
USG Rock Eagle 2017 - PWP at 1000 Days
Eric Sembrat136 vistas
SharePoint 2013 Performance Analysis - Robi Vončina por SPC Adriatics
SharePoint 2013 Performance Analysis - Robi VončinaSharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi Vončina
SPC Adriatics6.5K vistas
Cookies authentication por Rsilwal123
Cookies authenticationCookies authentication
Cookies authentication
Rsilwal123166 vistas
SPSUtah 2014 SharePoint 2013 Performance (Admin) por Brian Culver
SPSUtah 2014 SharePoint 2013 Performance (Admin)SPSUtah 2014 SharePoint 2013 Performance (Admin)
SPSUtah 2014 SharePoint 2013 Performance (Admin)
Brian Culver1.2K vistas
Load testing with Visual Studio and Azure - Andrew Siemer por Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew Siemer
Andrew Siemer5.4K vistas
Using cookies and sessions por Nuha Noor
Using cookies and sessionsUsing cookies and sessions
Using cookies and sessions
Nuha Noor1.2K vistas
Enterprise java unit-2_chapter-2 por sandeep54552
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2
sandeep54552138 vistas

Más de baabtra.com - No. 1 supplier of quality freshers

Agile methodology and scrum development por
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum developmentbaabtra.com - No. 1 supplier of quality freshers
1.5K vistas26 diapositivas
Acquiring new skills what you should know por
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should knowbaabtra.com - No. 1 supplier of quality freshers
1.5K vistas6 diapositivas
Baabtra.com programming at school por
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at schoolbaabtra.com - No. 1 supplier of quality freshers
1.2K vistas16 diapositivas
99LMS for Enterprises - LMS that you will love por
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love baabtra.com - No. 1 supplier of quality freshers
1.6K vistas10 diapositivas

Más de baabtra.com - No. 1 supplier of quality freshers(20)

Último

Igniting Next Level Productivity with AI-Infused Data Integration Workflows por
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
373 vistas86 diapositivas
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... por
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...ShapeBlue
48 vistas17 diapositivas
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... por
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...ShapeBlue
97 vistas28 diapositivas
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
130 vistas29 diapositivas
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TShapeBlue
81 vistas34 diapositivas
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsPriyanka Aash
103 vistas59 diapositivas

Último(20)

Igniting Next Level Productivity with AI-Infused Data Integration Workflows por Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software373 vistas
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... por ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue48 vistas
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... por ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue97 vistas
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc130 vistas
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue81 vistas
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash103 vistas
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... por ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue113 vistas
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... por ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 vistas
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... por James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson142 vistas
"Surviving highload with Node.js", Andrii Shumada por Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays49 vistas
DRBD Deep Dive - Philipp Reisner - LINBIT por ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue110 vistas
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... por The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue74 vistas
NTGapps NTG LowCode Platform por Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu287 vistas
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Data Integrity for Banking and Financial Services por Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely76 vistas
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue149 vistas
The Power of Heat Decarbonisation Plans in the Built Environment por IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 vistas
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue por ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue147 vistas

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