CookieOptions Class

Options used to create a new cookie.

Namespace
Microsoft.AspNetCore.Http
Assemblies
  • Microsoft.AspNetCore.Http.Features

Syntax

public class CookieOptions
class Microsoft.AspNetCore.Http.CookieOptions

Constructors

CookieOptions()

Creates a default cookie with a path of ‘/’.

public CookieOptions()

Properties

Microsoft.AspNetCore.Http.CookieOptions.Domain

Gets or sets the domain to associate the cookie with.

Return type:System.String
Returns:The domain to associate the cookie with.
public string Domain { get; set; }
Microsoft.AspNetCore.Http.CookieOptions.Expires

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

Return type:System.Nullable<System.DateTimeOffset>
Returns:The expiration date and time for the cookie.
public DateTimeOffset? Expires { get; set; }
Microsoft.AspNetCore.Http.CookieOptions.HttpOnly

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

Return type:System.Boolean
Returns:true if a cookie is accessible by client-side script; otherwise, false.
public bool HttpOnly { get; set; }
Microsoft.AspNetCore.Http.CookieOptions.Path

Gets or sets the cookie path.

Return type:System.String
Returns:The cookie path.
public string Path { get; set; }
Microsoft.AspNetCore.Http.CookieOptions.Secure

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

Return type:System.Boolean
Returns:true to transmit the cookie only over an SSL connection (HTTPS); otherwise, false.
public bool Secure { get; set; }