Sisk

Method

HttpResponseExtensions.WithCookie<THttpResponse>

Namespace
Sisk.Core.Http
Assembly
Sisk.Core.dll

WithCookie<THttpResponse>(THttpResponse, string, string, DateTime?, TimeSpan?, string?, string?, bool?, bool?, string?) #

Adds a cookie to the HTTP response with specified parameters.

C#
public static HttpResponse WithCookie<THttpResponse>(this THttpResponse response, string name, string value, DateTime? expires = null, TimeSpan? maxAge = null, string? domain = null, string? path = null, bool? secure = null, bool? httpOnly = null, string? sameSite = null) where THttpResponse : notnull, HttpResponse

Parameters #

response THttpResponse

name string

The name of the cookie.

value string

The value of the cookie.

expires DateTime?

The expiration date and time of the cookie. Can be null.

maxAge TimeSpan?

The maximum age of the cookie in seconds. Can be null.

domain string?

The domain for which the cookie is valid. Can be null.

path string?

The path for which the cookie is valid. Can be null.

secure bool?

A value indicating whether the cookie should only be sent over HTTPS. Can be null.

httpOnly bool?

A value indicating whether the cookie should be inaccessible to client-side scripts. Can be null.

sameSite string?

The SameSite attribute for the cookie. Can be null.

Returns #

HttpResponse

The modified HTTP response.

Type Parameters #

THttpResponse

Adds a cookie to the HTTP response using a Cookie object.

C#
public static HttpResponse WithCookie<THttpResponse>(this THttpResponse response, Cookie cookie) where THttpResponse : notnull, HttpResponse

Parameters #

response THttpResponse

cookie Cookie

The Cookie object to add.

Returns #

HttpResponse

The modified HTTP response.

Type Parameters #

THttpResponse

Type to search the documentation and the API reference.