Edit

Share via


CookieHandler.Write Method

Definition

Writes a cookie.

Overloads

Write(Byte[], Boolean, DateTime)

Writes a cookie associated with the current request that has the specified value, persistence, and expiration time.

Write(Byte[], String, DateTime)

Writes a cookie associated with the current request that has the specified name, value, and expiration time.

Write(Byte[], String, DateTime, HttpContext)

Writes a cookie associated with the specified request that has the specified name, value, and expiration time.

Write(Byte[], String, String, String, DateTime, Boolean, Boolean, HttpContext)

Writes a cookie associated with the specified request that has the specified name, value, domain, path, expiration time, and visibility.

Write(Byte[], Boolean, DateTime)

Writes a cookie associated with the current request that has the specified value, persistence, and expiration time.

public:
 void Write(cli::array <System::Byte> ^ value, bool isPersistent, DateTime tokenExpirationTime);
public void Write (byte[] value, bool isPersistent, DateTime tokenExpirationTime);
member this.Write : byte[] * bool * DateTime -> unit
Public Sub Write (value As Byte(), isPersistent As Boolean, tokenExpirationTime As DateTime)

Parameters

value
Byte[]

The cookie value.

isPersistent
Boolean

true if the cookie is persistent; false if the cookie is session-only, that is, only valid until the browser on the client is closed.

tokenExpirationTime
DateTime

The expiration time for the underlying token.

Exceptions

value is null or empty.

Remarks

If the isPersistent parameter is false, the cookie expiration time is set to DateTime.MinValue. If the isPersistent parameter is true, the cookie expiration time is set to the value of the PersistentSessionLifetime property if it is not null or, if the PersistentSessionLifetime property is null, the expiration time is set to the value of the tokenExpirationTime parameter.

The cookie name, domain and path are specified by the Name, Domain, and Path properties. The request is specified by Current. Whether the cookie should be sent only over SSL is specified by the RequireSsl property and whether the cookie should be hidden from client-side scripts is specified by the HideFromClientScript property.

Applies to

Write(Byte[], String, DateTime)

Writes a cookie associated with the current request that has the specified name, value, and expiration time.

public:
 void Write(cli::array <System::Byte> ^ value, System::String ^ name, DateTime expirationTime);
public void Write (byte[] value, string name, DateTime expirationTime);
member this.Write : byte[] * string * DateTime -> unit
Public Sub Write (value As Byte(), name As String, expirationTime As DateTime)

Parameters

value
Byte[]

The cookie value.

name
String

The name of the cookie.

expirationTime
DateTime

The expiration time for the cookie, or DateTime.MinValue for a session (session-only) cookie.

Exceptions

value is null or empty.

name is null or empty.

Remarks

The cookie domain and path are specified by the Domain and Path properties. The request is specified by HttpContext.Current. The request is specified by Current. Whether the cookie should be sent only over SSL is specified by the RequireSsl property and whether the cookie should be hidden from client-side scripts is specified by the HideFromClientScript property.

Applies to

Write(Byte[], String, DateTime, HttpContext)

Writes a cookie associated with the specified request that has the specified name, value, and expiration time.

public:
 void Write(cli::array <System::Byte> ^ value, System::String ^ name, DateTime expirationTime, System::Web::HttpContext ^ context);
public void Write (byte[] value, string name, DateTime expirationTime, System.Web.HttpContext context);
member this.Write : byte[] * string * DateTime * System.Web.HttpContext -> unit
Public Sub Write (value As Byte(), name As String, expirationTime As DateTime, context As HttpContext)

Parameters

value
Byte[]

The cookie value.

name
String

The name of the cookie.

expirationTime
DateTime

The expiration time for the cookie, or DateTime.MinValue for a session (session-only) cookie.

context
HttpContext

The HttpContext for the request.

Exceptions

value is null or empty.

name is null or empty.

Remarks

The cookie domain and path are specified by the Domain and Path properties. The request is specified by Current. Whether the cookie should be sent only over SSL is specified by the RequireSsl property and whether the cookie should be hidden from client-side scripts is specified by the HideFromClientScript property.

Applies to

Write(Byte[], String, String, String, DateTime, Boolean, Boolean, HttpContext)

Writes a cookie associated with the specified request that has the specified name, value, domain, path, expiration time, and visibility.

public:
 void Write(cli::array <System::Byte> ^ value, System::String ^ name, System::String ^ path, System::String ^ domain, DateTime expirationTime, bool requiresSsl, bool hideFromClientScript, System::Web::HttpContext ^ context);
public void Write (byte[] value, string name, string path, string domain, DateTime expirationTime, bool requiresSsl, bool hideFromClientScript, System.Web.HttpContext context);
member this.Write : byte[] * string * string * string * DateTime * bool * bool * System.Web.HttpContext -> unit
Public Sub Write (value As Byte(), name As String, path As String, domain As String, expirationTime As DateTime, requiresSsl As Boolean, hideFromClientScript As Boolean, context As HttpContext)

Parameters

value
Byte[]

The cookie value.

name
String

The name of the cookie.

path
String

The path for the cookie.

domain
String

The domain for the cookie.

expirationTime
DateTime

The expiration time for the cookie, or DateTime.MinValue for a session (session-only) cookie.

requiresSsl
Boolean

true if the cookie should only be used over an SSL connection; otherwise, false.

hideFromClientScript
Boolean

true if the cookie should be hidden from client script; otherwise, false.

context
HttpContext

The HttpContext for the request.

Exceptions

value is null or empty.

name is null or empty.

Applies to