Home > DeveloperSection > Forums > How to create a cookie in ASP.NET
Anoop Singh
Anoop Singh

Total Post:12

Points:84
Posted on    October-08-2010 7:35 AM

 ASP.Net ASP.Net 
Ratings:


 2 Reply(s)
 1425  View(s)
Rate this:
I am new in development please guide me to create cookie in ASP.NET


Uttam Misra

Total Post:124

Points:888
Posted on    October-08-2010 7:53 AM

Check this article anoop..

http://mindstick.com/Articles/c4e253f5-67dc-4211-8a1f-e29c17ce2943/

// Add this on the beginning of your .cs code file
using System;
 
 
// Use this line when you want to save a cookie
Response.Cookies["CookieName"].Value ="CookieValue";
// How long will cookie exist on client hard disk
Response.Cookies["CookieName"].Expires = DateTime.Now.AddDays(2);

// To add multiple key/value pairs in single cookie
Response.Cookies["EmployeeData"]["FirstName"] = "Mark";
Response.Cookies["EmployeeData"]["LastVisit"] = DateTime.Now.ToString();



Uttam Misra

Total Post:124

Points:888
Posted on    October-08-2010 8:05 AM


Don't want to miss updates? Please click the below button!

Follow MindStick