Rolosoft Documented Class Library
Encode Method (cookie, cookieProtection)
NamespacesRolosoft.WebControlsCookieSecureEncode(HttpCookie, CookieProtection)
Encodes a cookie with definable protection levels.
Declaration Syntax
C#Visual BasicVisual C++
public static HttpCookie Encode(
	HttpCookie cookie,
	CookieProtection cookieProtection
)
Public Shared Function Encode ( _
	cookie As HttpCookie, _
	cookieProtection As CookieProtection _
) As HttpCookie
public:
static HttpCookie^ Encode(
	HttpCookie^ cookie, 
	CookieProtection cookieProtection
)
Parameters
cookie (HttpCookie)
An object of type HttpCookie to encode.
cookieProtection (CookieProtection)
An enumeration of type CookieProtection defining the level of protection required.
Return Value
An object of type HttpCookie encoded and tamper proof.
Examples
The following C# example demonstrates how to Encode a cookie.
CopyC#
//Create a value to store
string myValueToStoreInCookie = "My details";

//Create a "standard" (unencrypted) HttpCookie
HttpCookie myCookie = new HttpCookie("MyCookieName",myValueToStoreInCookie);

//encrypt the "standard" cookie
HttpCookie myEncodedCookie = Rolosoft.WebControls.CookieSecure.Encode(myCookie, System.Web.Security.CookieProtection.Encryption);

//Add the encoded cookie to the response stream.
Page.Response.AppendCookie(myEncodedCookie);
Exceptions
ExceptionCondition
CookieSecureExceptionThrown if cookie is invalid or tamper is detected.

Assembly: Rolosoft.CookieSecure.Net (Module: Rolosoft.CookieSecure.Net) Version: 1.0.3134.36402 (1.0.0.0)