# Cookie

## Overview

The `Cookie` class provides Servoy developers with methods for performing basic cookie operations. It allows retrieving details about cookies, including their name, value, domain, path, and secure attribute.

## Functionality

This class offers methods to access essential properties of a cookie. Developers can retrieve the cookie’s domain, name, and path to understand its scope and access the value stored within the cookie. Additionally, it provides the ability to check whether the cookie is marked as secure, ensuring that it is transmitted over secure protocols.

## Methods Summarized

| Type                                                                           | Name                      | Summary                              |
| ------------------------------------------------------------------------------ | ------------------------- | ------------------------------------ |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [getDomain()](#getdomain) | Returns the cookie domain.           |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [getName()](#getname)     | Returns the cookie name.             |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [getPath()](#getpath)     | Returns the cookie path.             |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [getSecure()](#getsecure) | Returns the cookie secure attribute. |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [getValue()](#getvalue)   | Returns the cookie value.            |

## Methods Detailed

### getDomain()

Returns the cookie domain.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the value of the cookie, or an empty string if the cookie is null.

**Sample**

```js
var cookie = client.getCookie('cookieName')
var domain = cookie.getDomain();
```

### getName()

Returns the cookie name.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the name of the cookie, or an empty string if the cookie is null.

**Sample**

```js
var cookie = client.getCookie('cookieName')
var name = cookie.getName();
```

### getPath()

Returns the cookie path.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the path of the cookie, or an empty string if the cookie is null.

**Sample**

```js
var cookie = client.getCookie('cookieName')
var path = cookie.getPath();
```

### getSecure()

Returns the cookie secure attribute.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the cookie is marked as secure, false otherwise or if the cookie is null.

**Sample**

```js
var cookie = client.getCookie('cookieName')
var path = cookie.getSecure();
```

### getValue()

Returns the cookie value.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the value of the cookie, or an empty string if the cookie is null.

**Sample**

```js
var cookie = client.getCookie('cookieName')
var value = cookie.getValue();
```

***
