cookie에 관하여 (in terms)

cookier 쓰기

HttpCookie cookie = HttpContext.Current.Request.Cookies[settings.cookieName];
if (cookie == null)
    cookie = new HttpCookie(settings.cookieName, Guid.NewGuid().ToString());
    cookie.Expires = DateTime.Today.AddYears(1);

In ASP.NET terms, a page receives a CookieCollection as a property of an HttpRequest object (usually Request.Cookies) and returns a CookieCollection of updates as a property of an HttpResponse object (usually Response.Cookies). from On The Care and Handling of Cookies

Set cookier

HttpCookie cookie = new HttpCookie(Settings.CookieName, encryptedTicket);
cookie.Expires = expiryDate;

public static void RemoveCookie(Page page)
//Remove cookie if present
HttpCookie cookie = page.Request.Cookies[Settings.CookieName];
if (cookie != null)
HttpCookie expiredCookie = new HttpCookie(Settings.CookieName, “”);
expiredCookie.Expires = DateTime.Today.AddYears(-1);


cookie에 관하여 (in terms)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s