# Cookie

Namespace: **Wisej.Base**

Assembly: **Wisej.Framework** (4.0.0.0)

Represents an individual HTTP cookie.

{% tabs %}
{% tab title="C#" %}

```csharp
public class Cookie
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class Cookie
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) Cookie()

Creates a new instance of [Cookie](/api/wisej.base/general/cookie.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) Cookie(name, value)

Creates a new instance of [Cookie](/api/wisej.base/general/cookie.md).

| Name      | Type                                                          | Description              |
| --------- | ------------------------------------------------------------- | ------------------------ |
| **name**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the cookie.  |
| **value** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The value of the cookie. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Cookie(name, value, domain)

Creates a new instance of [Cookie](/api/wisej.base/general/cookie.md).

| Name       | Type                                                          | Description              |
| ---------- | ------------------------------------------------------------- | ------------------------ |
| **name**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the cookie.  |
| **value**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | The value of the cookie. |
| **domain** | [String](https://docs.microsoft.com/dotnet/api/system.string) |                          |

### ![](/files/hsR4ok3152WyAf8J2C1u) Cookie(name, value, expires)

Creates a new instance of [Cookie](/api/wisej.base/general/cookie.md).

| Name        | Type                                                              | Description                             |
| ----------- | ----------------------------------------------------------------- | --------------------------------------- |
| **name**    | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The name of the cookie.                 |
| **value**   | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The value of the cookie.                |
| **expires** | [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime) | The expiration date/time of the cookie. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Cookie(name, value, domain, expires)

Creates a new instance of [Cookie](/api/wisej.base/general/cookie.md).

| Name        | Type                                                              | Description                                                |
| ----------- | ----------------------------------------------------------------- | ---------------------------------------------------------- |
| **name**    | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The name of the cookie.                                    |
| **value**   | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The value of the cookie.                                   |
| **domain**  | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The domain, or partial domain, associated with the cookie. |
| **expires** | [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime) | The expiration date/time of the cookie.                    |

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) Domain

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the domain to associate the cookie with.

### ![](/files/hsR4ok3152WyAf8J2C1u) Expires

[DateTime](https://docs.microsoft.com/dotnet/api/system.datetime): Returns or sets the expiration date and time for the cookie.

### ![](/files/hsR4ok3152WyAf8J2C1u) HttpOnly

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the cookie cookie is a cookie that has the HttpOnly attribute, which prevents client-side scripts from accessing the cookie's data. <mark style="color:blue;background-color:green;">Since 4.0.0</mark>

Cookies with the HttpOnly attribute set to true can only be created during the handling of an HTTP request; it is not possible to set an HttpOnly cookie during a WebSocket request. If you need to create an HttpOnly cookie while using WebSocket, you must do so during the initial execution of Program.Main(). You can determine whether the application is responding to an HTTP or WebSocket request by examining the Application.IsWebSocket property.

### ![](/files/hsR4ok3152WyAf8J2C1u) Name

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the name for the [Cookie](/api/wisej.base/general/cookie.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) Path

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the path of the [Cookie](/api/wisej.base/general/cookie.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) SameSite

[SameSiteMode](/api/wisej.base/general/cookie/wisej.base.cookie.samesitemode.md): Returns or sets the value for the SameSite attribute of the cookie. The default value is [Unspecified](/api/wisej.base/general/cookie/wisej.base.cookie.samesitemode.md#fields).

### ![](/files/hsR4ok3152WyAf8J2C1u) Secure

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.

### ![](/files/hsR4ok3152WyAf8J2C1u) Value

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets an individual cookie value.

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) ToServerString()

Returns the string representation of the cookie.

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.base/general/cookie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
