.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Cache >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Read and Write values into Cookies in asp.net

Posted By:Rahul       Posted Date: October 29, 2008    Points: 10    Category: Cache    URL: http://www.dotnetspark.com  

Below is the code to write into cookie and to retrive value from cookie.This will help you to do basic Cookie operation.

To add value inside cookie

HttpCookie myCookie = new HttpCookie("myCookie");
myCookie.Values.Add("username", "UserNameToInsert");
myCookie.Values.Add("password", "PasswordToInsert");

 To retrive the value from Cookie

 HttpCookie cookie = Request.Cookies.Get("myCookie");
 string UserName= cookie.Values["username"];
 string Password= cookie.Values["password"];



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend