By using HttpCookies class
HttpCookie StudentCookies = new HttpCookie("StudentCookies");
StudentCookies.Value = TextBox1.Text;
StudentCookies.Expires = DateTime.Now.AddHours(1);
By using Response directly
Response.Cookies["StudentCookies"].Value = TextBox1.Text;
multiple values in same cookie
Response.Cookies["StudentCookies"]["RollNumber"] = TextBox1.Text;
Response.Cookies["StudentCookies"]["FirstName"] = "Anu";
Response.Cookies["StudentCookies"]["LastName"] = "Menon";
How to Retrieve a Cookie Value?
For httpcookie class and response directly
string val = Request.Cookies["StudentCookies"].Value;
For multiple cookies:
val = Request.Cookies["StudentCookies"]["RollNumber"];
val= val+ " " + Request.Cookies["StudentCookies"]["FirstName"];
val = val+ " " +Request.Cookies["StudentCookies"]["LastName"];
Label1.Text = val;
Difference between session and
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 is used for send the data from
client side to server side.
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 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
We can used any amount of data and any
Hacking will be easy Hacking is difficult
Only ASCII character data type allowed No restrictions. Allows binary data also
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 .
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
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,
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Ph: + 91 – 495 40 25 550
Hilite Business Park,
Start up Village