You can use the following method to store a string value in cookie using C#.net 4.0
public static void StoreCookie(string name, string valueToStore)
{
var cookie = new HttpCookie(name) {Value = valueToStore, Expires = DateTime.Now.AddYears(1)};
HttpContext.Current.Response.Cookies.Add(cookie);
}
Here classes like "HttpCookie" and "HttpContext" needs to be used in order to access cookies from a class library.
Welcome
"Happy are those who dream dreams and are ready to pay the price to make them come true"
About Me
My Home @ google Map
- Dhanushka Athukorala
- Colombo, Western Province, Sri Lanka
- I'm a Microsoft Certified Professional (MCP-ASP.net) who is currently working as a Software Engineer @ Aeturnum. I have experience in windows, web, mobile application development using .net framework 2.0, 3.5, 4.0 and .net compact framework 2.0 and 3.5 and i have also carried out development projects in C++, C, VB.net, Java, PHP, Pl/SQL, SQL, XNA, AJAX, Jquery etc...
Blog Archive
-
▼
2010
(16)
-
▼
November
(8)
- JavaScript setAttribute not working for IE
- Flot, A pure JQuery Charting tool and How to get t...
- Object Oriented JQuery/JavaScript
- Store a value in cookie from a class project in AS...
- Truncate a paragraph to the last word
- Remove duplicate values from a list
- Set the check status of all check boxes in a page ...
- Get all the selected check box IDs in page using J...
-
▼
November
(8)
Followers
Posted by
Dhanushka Athukorala
Monday, November 15, 2010
Subscribe to:
Post Comments (Atom)