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
Member | Description | |
---|---|---|
Constructor | ||
CookieName | The name of the Cookie that is used. This value should always be set or overridden via the constructor. | |
CookieTimeoutInMonths | The timeout of a persistent cookie. | |
CookieExist | Determines whether the cookie exists public bool CookieExist();
|
|
GetId | 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();
|
|
Remove | Removes the cookie by clearing it out and expiring it immediately. public void Remove();
|
|
WriteCookie | 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);
|