SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
sanila.p
sanila222@gmail.com
www.facebook.com/username
twitter.com/sanila92
linkedin.com/sanila
session and cookies
get and post methods
Introduction
 Web appcation work on HTTPprotocol
HTTP protocol is a stateless protocol
It does not maintain the state between
requests
cookies
• A cookie is often used to identify a user.
• A cookie is a small file that the server embeds
on the user's computer.
• Common use of cookies is to remember users
between visits.
Uses of cookies
• Identification of a user session, user's
preferences.
• Cookies can also be used for travelling of data
from one page to another.
• Shopping cart contents
• Authentication
Ways of creating cookies
By using HttpCookies class
HttpCookie StudentCookies = new HttpCookie("StudentCookies");
StudentCookies.Value = TextBox1.Text;
StudentCookies.Expires = DateTime.Now.AddHours(1);
Response.Cookies.Add(StudentCookies);
By using Response directly
Response.Cookies["StudentCookies"].Value = TextBox1.Text;
Response.Cookies["StudentCookies"].ExpiresDateTime.Now.AddDays(1)
;
multiple values in same cookie
Response.Cookies["StudentCookies"]["RollNumber"] = TextBox1.Text;
Response.Cookies["StudentCookies"]["FirstName"] = "Anu";
Response.Cookies["StudentCookies"]["LastName"] = "Menon";
Response.Cookies["StudentCookies"].Expires =
DateTime.Now.AddDays(1);
How to Retrieve a Cookie Value?
For httpcookie class and response directly
method:
string val = Request.Cookies["StudentCookies"].Value;
For multiple cookies:
string val;
val = Request.Cookies["StudentCookies"]["RollNumber"];
val= val+ " " + Request.Cookies["StudentCookies"]["FirstName"];
val = val+ " " +Request.Cookies["StudentCookies"]["LastName"];
Label1.Text = val;
Example program:
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["cookie"];
if (cookie == null)
{
HttpCookie userCookie = new HttpCookie("cookie");
userCookie["Name"] = "sanila";
userCookie.Expires = DateTime.Now.AddSeconds(8);
Response.Cookies.Add(userCookie);
Label1.Text = "Cookie created at: " + DateTime.Now.ToString() + "<br /><br />";
}
else
{
string name = cookie["Name"];
Label1.Text += "Welcome " + name;
}
}
demo
Deleting cookies
For deleting cookies:
if (Request.Cookies["StudentCookies"] != null)
{
Response.Cookies["StudentCookies"].Expires =
DateTime.Now.AddDays(-1);
}
session
Session serve the same purpose of cookies
that is sessions are used to maintain the state
in between requests
Creating session variable
Session["FirstName"] = TextBox.Text;
Session["LastName"] = TextBox1.Text;
How to receive session variable
if (Session["UserName"] != null)
{
label1.Text = "Welcome : " + Session[“username"];
}
else
{
label1.Text= “please check your username” ;
}
Destroying the session itself
• Session.clear(); //clears all the session
variables
• Session.Abandon(); //destroys the whole
session
Example program
Difference between session and
cookies
cookies session
cookies are stored in the user's browser Sessions are stored in server
A cookie can keep information in the user's
browser until deleted by user or set as per the
timer. It will not be destroyed even if you
close the browser.
A session is available as long as the browser is
opened. Usercant disable the session. It will
be destroyed if you close the browser
Cookies can only store string Can store any object
we can save cookie for future reference Session can’t be.
HTTP methods
HTTP methods is used for send the data from
client side to server side.
GET METHOD
POST METHOD
comparison
GET METHOD POST METHOD
Data will be arranged in HTTP header by
appending to the URL as query string
Data will be arranged in HTTP message body.
Data is in query string so user can view the
data
Data is not shown to user
Less secured compared to POST method
because data is in query string so it will be
saved in browser history and web server logs
safer than GET method because data is not
saved in history or web server logs.
As data is saved in URL so its saves only 2048
bytes data
We can used any amount of data and any
format
Hacking will be easy Hacking is difficult
Only ASCII character data type allowed No restrictions. Allows binary data also
21
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
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
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
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
Contact Us

Más contenido relacionado

La actualidad más candente

Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …Jinglun Li
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & csssesharao puvvada
 
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web TechnologyAyes Chinmay
 
SEO best practices to increase your page speed
SEO best practices to increase your page speedSEO best practices to increase your page speed
SEO best practices to increase your page speedDigileap
 
IIW10 NASCAR for Sharing
IIW10 NASCAR for SharingIIW10 NASCAR for Sharing
IIW10 NASCAR for SharingWill Meyer
 
Introduction to web compoents
Introduction to web compoentsIntroduction to web compoents
Introduction to web compoentsRan Wahle
 
Internet and Web Technology (CLASS-3) [HTML & CSS]
Internet and Web Technology (CLASS-3) [HTML & CSS] Internet and Web Technology (CLASS-3) [HTML & CSS]
Internet and Web Technology (CLASS-3) [HTML & CSS] Ayes Chinmay
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-frameworkSakthi Bro
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoknaddison
 
Basic web security model
Basic web security modelBasic web security model
Basic web security modelG Prachi
 
Internet and Web Technology (CLASS-5) [HTML DOM]
Internet and Web Technology (CLASS-5) [HTML DOM] Internet and Web Technology (CLASS-5) [HTML DOM]
Internet and Web Technology (CLASS-5) [HTML DOM] Ayes Chinmay
 
WordPress Optimization Tips for Performance & Speed
WordPress Optimization Tips for Performance & SpeedWordPress Optimization Tips for Performance & Speed
WordPress Optimization Tips for Performance & SpeedMike Hale
 

La actualidad más candente (15)

Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …
 
Php cookies
Php cookiesPhp cookies
Php cookies
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & css
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
Sessions n cookies
Sessions n cookiesSessions n cookies
Sessions n cookies
 
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
 
SEO best practices to increase your page speed
SEO best practices to increase your page speedSEO best practices to increase your page speed
SEO best practices to increase your page speed
 
IIW10 NASCAR for Sharing
IIW10 NASCAR for SharingIIW10 NASCAR for Sharing
IIW10 NASCAR for Sharing
 
Introduction to web compoents
Introduction to web compoentsIntroduction to web compoents
Introduction to web compoents
 
Internet and Web Technology (CLASS-3) [HTML & CSS]
Internet and Web Technology (CLASS-3) [HTML & CSS] Internet and Web Technology (CLASS-3) [HTML & CSS]
Internet and Web Technology (CLASS-3) [HTML & CSS]
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicago
 
Basic web security model
Basic web security modelBasic web security model
Basic web security model
 
Internet and Web Technology (CLASS-5) [HTML DOM]
Internet and Web Technology (CLASS-5) [HTML DOM] Internet and Web Technology (CLASS-5) [HTML DOM]
Internet and Web Technology (CLASS-5) [HTML DOM]
 
WordPress Optimization Tips for Performance & Speed
WordPress Optimization Tips for Performance & SpeedWordPress Optimization Tips for Performance & Speed
WordPress Optimization Tips for Performance & Speed
 

Similar a Session and cookies,get and post methods

Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...
Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...
Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...Matthew Gerrior
 
Startup Institute NY - Authentication, Validation, and Basic Testing
Startup Institute NY - Authentication, Validation, and Basic TestingStartup Institute NY - Authentication, Validation, and Basic Testing
Startup Institute NY - Authentication, Validation, and Basic TestingMatthew Gerrior
 
Enterprise java unit-2_chapter-2
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2sandeep54552
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSDegu8
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servletsvishal choudhary
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.pptJayaprasanna4
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introductionProgrammer Blog
 
C# cookieless session id and application state
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application stateMalav Patel
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Using sharepoint to solve business problems #spsnairobi2014
Using sharepoint to solve business problems #spsnairobi2014Using sharepoint to solve business problems #spsnairobi2014
Using sharepoint to solve business problems #spsnairobi2014Amos Wachanga
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In PhpHarit Kothari
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3sandeep54552
 
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance Albert Hoitingh
 

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

Cookies & Session
Cookies & SessionCookies & Session
Cookies & Session
 
Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...
Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...
Startup Institute NY (Summer 2016) - Authentication, Validation, and Basic Te...
 
Startup Institute NY - Authentication, Validation, and Basic Testing
Startup Institute NY - Authentication, Validation, and Basic TestingStartup Institute NY - Authentication, Validation, and Basic Testing
Startup Institute NY - Authentication, Validation, and Basic Testing
 
Enterprise java unit-2_chapter-2
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2
 
Cookie
CookieCookie
Cookie
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.ppt
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
APEX & Cookie Monster
APEX & Cookie MonsterAPEX & Cookie Monster
APEX & Cookie Monster
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
C# cookieless session id and application state
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application state
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Using sharepoint to solve business problems #spsnairobi2014
Using sharepoint to solve business problems #spsnairobi2014Using sharepoint to solve business problems #spsnairobi2014
Using sharepoint to solve business problems #spsnairobi2014
 
Session,cookies
Session,cookiesSession,cookies
Session,cookies
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
 
Sessions&cookies
Sessions&cookiesSessions&cookies
Sessions&cookies
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
 
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance
Microsoft 365 Security & Compliance User Group - Microsoft Teams compliance
 

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

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

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 

Último (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 

Session and cookies,get and post methods

  • 1.
  • 3. Introduction  Web appcation work on HTTPprotocol HTTP protocol is a stateless protocol It does not maintain the state between requests
  • 4. cookies • A cookie is often used to identify a user. • A cookie is a small file that the server embeds on the user's computer. • Common use of cookies is to remember users between visits.
  • 5. Uses of cookies • Identification of a user session, user's preferences. • Cookies can also be used for travelling of data from one page to another. • Shopping cart contents • Authentication
  • 7. By using HttpCookies class HttpCookie StudentCookies = new HttpCookie("StudentCookies"); StudentCookies.Value = TextBox1.Text; StudentCookies.Expires = DateTime.Now.AddHours(1); Response.Cookies.Add(StudentCookies);
  • 8. By using Response directly Response.Cookies["StudentCookies"].Value = TextBox1.Text; Response.Cookies["StudentCookies"].ExpiresDateTime.Now.AddDays(1) ;
  • 9. multiple values in same cookie Response.Cookies["StudentCookies"]["RollNumber"] = TextBox1.Text; Response.Cookies["StudentCookies"]["FirstName"] = "Anu"; Response.Cookies["StudentCookies"]["LastName"] = "Menon"; Response.Cookies["StudentCookies"].Expires = DateTime.Now.AddDays(1);
  • 10. How to Retrieve a Cookie Value? For httpcookie class and response directly method: string val = Request.Cookies["StudentCookies"].Value; For multiple cookies: string val; val = Request.Cookies["StudentCookies"]["RollNumber"]; val= val+ " " + Request.Cookies["StudentCookies"]["FirstName"]; val = val+ " " +Request.Cookies["StudentCookies"]["LastName"]; Label1.Text = val;
  • 11. Example program: protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["cookie"]; if (cookie == null) { HttpCookie userCookie = new HttpCookie("cookie"); userCookie["Name"] = "sanila"; userCookie.Expires = DateTime.Now.AddSeconds(8); Response.Cookies.Add(userCookie); Label1.Text = "Cookie created at: " + DateTime.Now.ToString() + "<br /><br />"; } else { string name = cookie["Name"]; Label1.Text += "Welcome " + name; } } demo
  • 12. Deleting cookies For deleting cookies: if (Request.Cookies["StudentCookies"] != null) { Response.Cookies["StudentCookies"].Expires = DateTime.Now.AddDays(-1); }
  • 13. session Session serve the same purpose of cookies that is sessions are used to maintain the state in between requests
  • 14. Creating session variable Session["FirstName"] = TextBox.Text; Session["LastName"] = TextBox1.Text;
  • 15. How to receive session variable if (Session["UserName"] != null) { label1.Text = "Welcome : " + Session[“username"]; } else { label1.Text= “please check your username” ; }
  • 16. Destroying the session itself • Session.clear(); //clears all the session variables • Session.Abandon(); //destroys the whole session
  • 18. Difference between session and cookies cookies session cookies are stored in the user's browser Sessions are stored in server A cookie can keep information in the user's browser until deleted by user or set as per the timer. It will not be destroyed even if you close the browser. A session is available as long as the browser is opened. Usercant disable the session. It will be destroyed if you close the browser Cookies can only store string Can store any object we can save cookie for future reference Session can’t be.
  • 19. HTTP methods HTTP methods is used for send the data from client side to server side. GET METHOD POST METHOD
  • 20. comparison GET METHOD POST METHOD Data will be arranged in HTTP header by appending to the URL as query string Data will be arranged in HTTP message body. Data is in query string so user can view the data Data is not shown to user Less secured compared to POST method because data is in query string so it will be saved in browser history and web server logs safer than GET method because data is not saved in history or web server logs. As data is saved in URL so its saves only 2048 bytes data We can used any amount of data and any format Hacking will be easy Hacking is difficult Only ASCII character data type allowed No restrictions. Allows binary data also
  • 21. 21 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
  • 22. 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.
  • 23. 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 Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 24. 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 Contact Us