Table of Contents

Method WithCookie<THttpResponse>

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

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

Sets a cookie and sends it in the response to be set by the client.

public static THttpResponse 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 : HttpResponse

Parameters

response THttpResponse

The HttpResponse object.

name string

The cookie name.

value string

The cookie value.

expires DateTime?

The cookie expirity date.

maxAge TimeSpan?

The cookie max duration after being set.

domain string?

The domain where the cookie will be valid.

path string?

The path where the cookie will be valid.

secure bool?

Determines if the cookie will only be stored in an secure context.

httpOnly bool?

Determines if the cookie will be only available in the HTTP context.

sameSite string?

The cookie SameSite parameter.

Returns

THttpResponse

Type Parameters

THttpResponse

The type which implements HttpResponse.

Sets a cookie and sends it in the response to be set by the client.

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

Parameters

response THttpResponse

The HttpResponse object.

cookie Cookie

The cookie object.

Returns

THttpResponse

Type Parameters

THttpResponse

The type which implements HttpResponse.