Class CookieManager

A generic Cookie class that manages an individual Cookie by localizing the cookie management into a single class. This means the Cookie's name and and timing is abstracted.

The GetId() method is the key method here which retrieves a Cookie Id. If the cookie exists it returns the value, otherwise it generates a new Id and creates the cookie with the specs of the class and

It's recommended you store this class as a static member off another object to have

public class CookieManager : object

Class Members




The name of the Cookie that is used. This value should always be set or overridden via the constructor.


The timeout of a persistent cookie.


Determines whether the cookie exists

public bool CookieExist()


Generic routine to create a cookie consistently and with the proper HTTP settings applied

public virtual HttpCookie CreateCookie(string name,     string value,     bool secure)


This is the key method of this class that retrieves the value of the cookie. This method is meant as retrieving an ID value. If the value doesn't exist it is created and the cookie set and the value returned. If the Cookie exists the value is retrieved and returned.

public string GetId()


Removes the cookie by clearing it out and expiring it immediately.

public void Remove()


Writes the cookie into the response stream with the value passed. The value is always the UserId.

public void WriteCookie(string Value,     bool NonPersistent)

public void WriteCookie(string Value)


Namespace: Westwind.Web
Assembly: westwind.web.dll

© West Wind Technologies, 1996-2016 • Updated: 12/12/15
Comment or report problem with topic