# WsCookie

## Overview

An HTTP cookie representation provides methods to manage and manipulate various attributes of cookies in an application. The cookie includes properties such as `name` and `value`, which hold its key and content respectively. Attributes like `domain`, `path`, and `maxAge` define the cookie's scope and lifetime, while flags such as `secure` and `httpOnly` enhance security by restricting the transmission protocol and JavaScript accessibility.

Additional attributes like `comment` provide metadata about the cookie's purpose, and `version` ensures compatibility with specific cookie protocols. This representation also supports methods for checking and modifying these attributes dynamically.

## Properties Summarized

| Type                                                       | Name                  | Summary               |
| ---------------------------------------------------------- | --------------------- | --------------------- |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [comment](#comment)   | Cookie comment.       |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [domain](#domain)     | Cookie domain.        |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [httpOnly](#httponly) | Cookie httpOnly flag. |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [maxAge](#maxage)     | Cookie maxAge.        |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [name](#name)         | Cookie name.          |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [path](#path)         | Cookie path.          |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [secure](#secure)     | Cookie secure flag.   |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [value](#value)       | Cookie value.         |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [version](#version)   | Cookie version.       |

## Properties Detailed

### comment

Cookie comment.\
Specifies a comment that describes a cookie's purpose.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.comment = 'yummy';
```

### domain

Cookie domain.\
Specifies the domain within which this cookie should be presented.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.domain = 'example.com';
```

### httpOnly

Cookie httpOnly flag.\
Marks or unmarks this Cookie as HttpOnly

**Type**\
[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.httpOnly = true;
```

### maxAge

Cookie maxAge.\
Sets the maximum age in seconds for this Cookie.

**Type**\
[Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.maxAge = 3600;
```

### name

Cookie name.

The cookie name allows only a sequence of non-special, non-white space characters, see\
the cookie spec <https://tools.ietf.org/html/rfc2965>

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.name = 'doublechocolate';
```

### path

Cookie path.\
Specifies a path for the cookie to which the client should return the cookie.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.path = '/subfolder';
```

### secure

Cookie secure flag.\
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.

**Type**\
[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.secure = true;
```

### value

Cookie value.

The cookie value allows only a sequence of non-special, non-white space characters, see\
the cookie spec <https://tools.ietf.org/html/rfc2965>

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.value = 'mint';
```

### version

Cookie version.\
Sets the version of the cookie protocol that this Cookie complies with.

**Type**\
[Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
var cookie = plugins.rest_ws.createCookie('chocolate', 'chip');
cookie.version = 1;
```

***


---

# 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.servoy.com/reference/servoyextensions/server-plugins/rest_ws/wscookie.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.
