Click or drag to resize

CookieExtensionsAddCookie Method (HttpResponse, String, String, CookieAttrs, String, Int32)

Create a cookie and add it to the response. You should specify Encoded if the cookie value might contain characters invalid in a cookie value. Use GetEncodedCookieValue(HttpRequest, String) when retrieving values from encoded cookies. Specify Secure if the cookie should be Secure.

Namespace:  NetQuarry.Net
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
public static void AddCookie(
	this HttpResponse response,
	string name,
	string value,
	CookieAttrs attrs,
	string domain = null,
	int expiresDays = 0
)

Parameters

response
Type: System.WebHttpResponse
The response.
name
Type: SystemString
The cookie name.
value
Type: SystemString
The cookie value.
attrs
Type: NetQuarry.NetCookieAttrs
Attributes affecting cookie creation (e.g. Encoded, Secure).
domain (Optional)
Type: SystemString
The optional cookie domain.
expiresDays (Optional)
Type: SystemInt32
The optional cookie expiration, in days from the current date. This is set on the cookie only if non-zero.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HttpResponse. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
See http://stackoverflow.com/questions/1969232/allowed-characters-in-cookies for a discussion of problematic cookie values that require encoding. When so specified, the value is encoded using the .Net HttpUtility.UrlEncode() method which is at least approximately equivalent to the javascript encodeURIComponent() method. Use GetEncodedCookieValue(HttpRequest, String) when retrieving values from such cookies.
See Also