Saturday, 04 May 2013 13:54

using HttpCookie in asp.net application

Written by 
Rate this item
(0 votes)

HttpCookie is a very good way to store small amount of data
in asp.net application/website.you can access cookie value in
any page once set in a page.cookie can stay for long time in the
user's computer.

in some cases cookies are very useful in application.how to use
cookie in detail -

//fist check whether cookie exists(created before)
HttpCookie Mitsol_HttpCookieComid = Request.Cookies["Mitsol_HttpCookieComId"];

//if exists
if (Mitsol_HttpCookieComid != null)
{ //do anything with the cookie value }

//not exists create new cookie
else
{
HttpCookie Mitsol_HttpCookieComId = new HttpCookie("Mitsol_HttpCookieComId");
Mitsol_HttpCookieComId.Value = id.ToString();
Response.Cookies.Add(Mitsol_HttpCookieComId);

}

Read 2740 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.