# CookieCollection

Namespace: **Wisej.Base**

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

Manages the collection of cookies for the current application.

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

```csharp
public class CookieCollection : IList<Cookie>, ICollection<Cookie>, IEnumerable<Cookie>, IEnumerable
```

{% endtab %}

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

```visual-basic
Public Class CookieCollection
    Inherits IList(Of Cookie)
    Implements ICollection(Of Cookie), IEnumerable(Of Cookie), IEnumerable
```

{% endtab %}
{% endtabs %}

## Properties

### ![](/files/uCY6T77rh488FWHzpJ6P)Count

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns the number of [Cookie](/api/v3.0/wisej.base/general/cookie.md) items in the collection.

### ![](/files/uCY6T77rh488FWHzpJ6P)Item(name)

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns the [Cookie](/api/v3.0/wisej.base/general/cookie.md) with a specific name from a [CookieCollection](/api/v3.0/wisej.base/general/wisej.base.cookiecollection.md).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) *name* is null.

### ![](/files/uCY6T77rh488FWHzpJ6P)Item(index)

[Cookie](/api/v3.0/wisej.base/general/cookie.md): Returns the [Cookie](/api/v3.0/wisej.base/general/cookie.md) with a specific name from a [CookieCollection](/api/v3.0/wisej.base/general/wisej.base.cookiecollection.md).

**Throws:**

* [IndexOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.indexoutofrangeexception) *index* is out of range.

## Methods

### ![](/files/uCY6T77rh488FWHzpJ6P)Add(cookie)

Adds a cookie to the collection.

| Parameter  | Type                                             | Description        |
| ---------- | ------------------------------------------------ | ------------------ |
| **cookie** | [Cookie](/api/v3.0/wisej.base/general/cookie.md) | The cookie to add. |

### ![](/files/uCY6T77rh488FWHzpJ6P)Add(name, value)

Adds a new cookie to the collection.

| Parameter | Type                                                                | Description                            |
| --------- | ------------------------------------------------------------------- | -------------------------------------- |
| **name**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The case-sensitive name of the cookie. |
| **value** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The value of the new cookie to add.    |

**Returns:** [Cookie](/api/v3.0/wisej.base/general/cookie.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)Add(name, value, domain)

Adds a new cookie to the collection.

| Parameter  | Type                                                                | Description                                                |
| ---------- | ------------------------------------------------------------------- | ---------------------------------------------------------- |
| **name**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The case-sensitive name of the cookie.                     |
| **value**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The value of the new cookie to add.                        |
| **domain** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The domain, or partial domain, associated with the cookie. |

**Returns:** [Cookie](/api/v3.0/wisej.base/general/cookie.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)Add(name, value, expires)

Adds a new cookie to the collection.

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

**Returns:** [Cookie](/api/v3.0/wisej.base/general/cookie.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)Add(name, value, domain, expires)

Adds a new cookie to the collection.

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

**Returns:** [Cookie](/api/v3.0/wisej.base/general/cookie.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)Clear()

Delete all cookies from the collection. NOTE: Cookies are only removed from the collection, not from the client. You need to set the expiration date to remove it from the client.

### ![](/files/uCY6T77rh488FWHzpJ6P)Contains(cookie)

Determines whether the cookie is present in the collection.

| Parameter  | Type                                             | Description           |
| ---------- | ------------------------------------------------ | --------------------- |
| **cookie** | [Cookie](/api/v3.0/wisej.base/general/cookie.md) | The cookie to locate. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean).

### ![](/files/uCY6T77rh488FWHzpJ6P)CopyTo(array, index)

Copies the cookie collection to a compatible one-dimensional array, starting at the specified index of the target array.

| Parameter | Type                                                              | Description                                                                      |
| --------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| **array** | [Cookie\[\]](/api/v3.0/wisej.base/general/cookie.md)              | The one-dimensional System.Array that is the destination of the elements copied. |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32) | The zero-based index in array at which copying begins.                           |

### ![](/files/uCY6T77rh488FWHzpJ6P)Get(name)

Returns the cookie with the specified name.

| Parameter | Type                                                                | Description                                      |
| --------- | ------------------------------------------------------------------- | ------------------------------------------------ |
| **name**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The case-sensitive name of the cookie to locate. |

**Returns:** [Cookie](/api/v3.0/wisej.base/general/cookie.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)GetEnumerator()

**Returns:** [IEnumerator\<Cookie>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerator).

### ![](/files/uCY6T77rh488FWHzpJ6P)IndexOf(cookie)

Searches for the specified cookie and returns the zero-based index of the first occurrence.

| Parameter  | Type                                             | Description           |
| ---------- | ------------------------------------------------ | --------------------- |
| **cookie** | [Cookie](/api/v3.0/wisej.base/general/cookie.md) | The cookie to locate. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32).

### ![](/files/uCY6T77rh488FWHzpJ6P)IndexOf(name)

Searches for the specified cookie by name and returns the zero-based index of the first occurrence.

| Parameter | Type                                                                | Description                               |
| --------- | ------------------------------------------------------------------- | ----------------------------------------- |
| **name**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The case-sensitive name cookie to locate. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32).

### ![](/files/uCY6T77rh488FWHzpJ6P)Remove(cookie)

Removes the specified cookie from the collection. NOTE: Cookies are only removed from the collection, not from the client. You need to set the expiration date to remove it from the client.

| Parameter  | Type                                             | Description                               |
| ---------- | ------------------------------------------------ | ----------------------------------------- |
| **cookie** | [Cookie](/api/v3.0/wisej.base/general/cookie.md) | The cookie to remove from the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true if item is successfully removed; otherwise, false.

### ![](/files/uCY6T77rh488FWHzpJ6P)Remove(name)

Removes the specified cookie from the collection. NOTE: Cookies are only removed from the collection, not from the client. You need to set the expiration date to remove it from the client.

| Parameter | Type                                                                | Description                                                          |
| --------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- |
| **name**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The case-sensitive name of the cookie to remove from the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true if item is successfully removed; otherwise, false.

### ![](/files/uCY6T77rh488FWHzpJ6P)RemoveAt(index)

Removes the cookie at the specified index. NOTE: Cookies are only removed from the collection, not from the client. You need to set the expiration date to remove it from the client.

| Parameter | Type                                                              | Description                                    |
| --------- | ----------------------------------------------------------------- | ---------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32) | The zero-based index of the element to remove. |


---

# 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/v3.0/wisej.base/general/wisej.base.cookiecollection.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.
