Dela via


CookieOptions Class

Definition

Options used to create a new cookie.

public ref class CookieOptions
public class CookieOptions
type CookieOptions = class
Public Class CookieOptions
Inheritance
CookieOptions

Remarks

A CookieOptions instance is intended to govern the behavior of an individual cookie. Reusing the same CookieOptions instance across multiple cookies can lead to unintended consequences, such as modifications affecting multiple cookies. We recommend instantiating a new CookieOptions object for each cookie to ensure that the configuration is applied independently.

Constructors

CookieOptions()

Creates a default cookie with a path of '/'.

CookieOptions(CookieOptions)

Creates a copy of the given CookieOptions.

Properties

Domain

Gets or sets the domain to associate the cookie with.

Expires

Gets or sets the expiration date and time for the cookie.

Extensions

Gets a collection of additional values to append to the cookie.

HttpOnly

Gets or sets a value that indicates whether a cookie is inaccessible by client-side script.

IsEssential

Indicates if this cookie is essential for the application to function correctly. If true then consent policy checks may be bypassed. The default value is false.

MaxAge

Gets or sets the max-age for the cookie.

Path

Gets or sets the cookie path.

SameSite

Gets or sets the value for the SameSite attribute of the cookie. The default value is Unspecified

Secure

Gets or sets a value that indicates whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.

Methods

CreateCookieHeader(String, String)

Creates a SetCookieHeaderValue using the current options.

Applies to