Skip to main content
Version: 4.1

Cookie

Namespace: Wisej.Base

Assembly: Wisej.Framework (4.1.0.0)

Represents an individual HTTP cookie.

public class Cookie

Constructors​

Creates a new instance of Cookie.

Creates a new instance of Cookie.

NameTypeDescription
nameStringThe name of the cookie.
valueStringThe value of the cookie.

Creates a new instance of Cookie.

NameTypeDescription
nameStringThe name of the cookie.
valueStringThe value of the cookie.
domainStringThe domain, or partial domain, associated with the cookie.

Creates a new instance of Cookie.

NameTypeDescription
nameStringThe name of the cookie.
valueStringThe value of the cookie.
expiresDateTimeThe expiration date/time of the cookie.

Creates a new instance of Cookie.

NameTypeDescription
nameStringThe name of the cookie.
valueStringThe value of the cookie.
domainStringThe domain, or partial domain, associated with the cookie.
expiresDateTimeThe expiration date/time of the cookie.

Creates a new instance of Cookie.

NameTypeDescription
nameStringThe name of the cookie.
valueStringThe value of the cookie.
domainStringThe domain, or partial domain, associated with the cookie.
expiresDateTimeThe expiration date/time of the cookie.
secureBooleanWhether the cookie is secure.
httpOnlyBooleanWhether the cookie is HttpOnly.
sameSiteSameSiteModeThe SameSite mode of the cookie.

Properties​

Instance member Domain​

String: Returns or sets the domain to associate the cookie with.

Value: The name of the domain to associate the cookie with. The default value is the current domain.

Instance member Expires​

DateTime: Returns or sets the expiration date and time for the cookie.

Value: The time of day (on the client) at which the cookie expires.

Instance member HttpOnly 4.0.0+​

Boolean: Returns or sets whether the cookie cookie is a cookie that has the HttpOnly attribute, which prevents client-side scripts from accessing the cookie's data.

Cookies with the HttpOnly attribute set to true can only be created during the handling of an HTTP request; it is not possible to set an HttpOnly cookie during a WebSocket request. If you need to create an HttpOnly cookie while using WebSocket, you must do so during the initial execution of Program.Main().

You can determine whether the application is responding to an HTTP or WebSocket request by examining the Application.IsWebSocket property.

Instance member Name​

String: Returns or sets the name for the Cookie.

Value: The name for the Cookie.

Instance member Path​

String: Returns or sets the path of the Cookie.

Value: The path of the Cookie.

Instance member SameSite​

SameSiteMode: Returns or sets the value for the SameSite attribute of the cookie. The default value is Unspecified.

Instance member Secure​

Boolean: Returns or sets whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.

Value: true to transmit the cookie over an SSL connection (HTTPS); otherwise, false. The default value is false.

Instance member Value​

String: Returns or sets an individual cookie value.

Value: The value of the cookie. The default value is a null reference.

The value is stored and returned unencoded. Wisej percent-encodes it (EscapeDataString) when sending the cookie to the browser and decodes it when reading it back, so values containing spaces, non-ASCII or reserved characters (;``,``"``\) round-trip correctly.

Methods​

Instance member ToServerString()​

Returns the string representation of the cookie.

Returns: String.