Class

# WebCookieManager

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to get and set cookies connected with the app.

You can **only** get an instance of this object via the `WebSession.Cookies<websession.cookies>` property.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                              | Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Returns                            | Shared |
|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `Count<webcookiemanager.count>`   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | `Integer</api/data_types/integer>` |        |
| `NameAt<webcookiemanager.nameat>` | index As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | `String</api/data_types/string>`   |        |
| `Remove<webcookiemanager.remove>` | name As `String</api/data_types/string>`, domain As `String</api/data_types/string>` = "", path As `String</api/data_types/string>` = "", secure As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, httpOnly As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, sameSite As `SameSiteStrength<webcookiemanager.samesitestrength>` = `SameSiteStrength.Lax<webcookiemanager.samesitestrength>`                                                                                                                           |                                    |        |
| `Set<webcookiemanager.set>`       | name As `String</api/data_types/string>`, value As `String</api/data_types/string>`, expiration As `DateTime</api/data_types/datetime>` = `Nil</api/language/nil>`, domain As `String</api/data_types/string>` = "", path As `String</api/data_types/string>` = "", secure As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, httpOnly As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, sameSite As `SameSiteStrength<webcookiemanager.samesitestrength>` = `SameSiteStrength.Lax<webcookiemanager.samesitestrength>` |                                    |        |
| `Value<webcookiemanager.value>`   | name As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | `String</api/data_types/string>`   |        |

## Enumerations

<div id="webcookiemanager.samesitestrength">

<div class="rst-class">

forsearch

</div>

</div>

WebCookieManager.SameSiteStrength

### SameSiteStrength

> Controls when browsers send your cookie with requests.
>
> | Enum   | Description                                                                                                                                                    |
> |--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | None   | The cookie is sent with all requests, including cross-site ones. Browsers require the Secure flag for this setting, which the framework automatically applies. |
> | Lax    | The cookie is sent with same-site requests and top-level navigation, but blocked from cross-site embedded requests.                                            |
> | Strict | The cookie is only sent with same-site requests - provides maximum protection but may break legitimate cross-site functionality.                               |
>
> A same-site request comes from the same domain as your application (e.g., if your app is on example.com, requests from example.com or www.example.com). A cross-site request originates from a different domain, such as when your site is embedded in an iframe on thirdparty.com or called via AJAX from anotherdomain.org.

## Method descriptions

<div id="webcookiemanager.count">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebCookieManager.Count

**Count** As `Integer</api/data_types/integer>`

> Returns the number of cookies created by the app.

<div id="webcookiemanager.nameat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebCookieManager.NameAt

**NameAt**(index As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> Returns the name of the cookie at the *index* passed.

<div id="webcookiemanager.remove">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebCookieManager.Remove

**Remove**(name As `String</api/data_types/string>`, domain As `String</api/data_types/string>` = "", path As `String</api/data_types/string>` = "", secure As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, httpOnly As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, sameSite As `SameSiteStrength<webcookiemanager.samesitestrength>` = `SameSiteStrength.Lax<webcookiemanager.samesitestrength>`)

> Removes the cookie with the *name*, *domain* and *path* passed.

<div id="webcookiemanager.set">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebCookieManager.Set

**Set**(name As `String</api/data_types/string>`, value As `String</api/data_types/string>`, expiration As `DateTime</api/data_types/datetime>` = `Nil</api/language/nil>`, domain As `String</api/data_types/string>` = "", path As `String</api/data_types/string>` = "", secure As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, httpOnly As `Boolean</api/data_types/boolean>` = `False</api/language/false>`, sameSite As `SameSiteStrength<webcookiemanager.samesitestrength>` = `SameSiteStrength.Lax<webcookiemanager.samesitestrength>`)

> Sets the cookie to the values passed. If *sameSite* is set to `SameSiteStrength.Lax<webcookiemanager.samesitestrength>`, secure will always be `True</api/language/true>`, regardless of what you've entered.
>
> | Parameter  | Description                                                                                                                                                                                                                                                                                              |
> |------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | name       | Name of the cookie to set so you can retrieve the value later with the Value method.                                                                                                                                                                                                                     |
> | value      | A value to store on the user's browser.                                                                                                                                                                                                                                                                  |
> | expiration | Date after which the cookie will no longer be available.                                                                                                                                                                                                                                                 |
> | domain     | Limits access to the cookie to the domain specified.                                                                                                                                                                                                                                                     |
> | path       | Limits access to the cookie to the path specified.                                                                                                                                                                                                                                                       |
> | secure     | If `True</api/language/true>`, the cookie can only be accessed via secure (https) connections.                                                                                                                                                                                                           |
> | httpOnly   | If `True</api/language/true>`, the cookie can only be accessed via (https) connections.                                                                                                                                                                                                                  |
> | sameSite   | Defines the context in which the cookies are sent by the browser to the server. The default value None means cookies are sent in all contexts. With Lax, cookies are not sent on normal cross-site subrequests (images or frames to a 3rd party site). With Strict cookies are only sent to your server. |
>
> If you don't provide an expiration date, your cookie will expire when the session ends. If you do provide an expiration date, the cookie will expire as late as the provided expiration date because browsers can decide to discard cookies before they expire.

<div id="webcookiemanager.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebCookieManager.Value

**Value**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Returns the cookie whose *name* was passed.

## Notes

Session cookies are deleted by the browser when the browser decides that the session has ended.

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `WebSession.Cookies<websession.cookies>` property.

</div>
