---
schema_version: "1"
id: 0d36416eb90a0e93f04d89790efed1f74c51f59b3cb7c1ef9d526736fee89598
title: SetCookie
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/guides/mc-programmatic-content/ssjs_platformClientBrowserSetCookie.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_platformClientBrowserSetCookie.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: de89d004e47c87195049489ee1e146f6ac3c94de5f5ccd1e6cca11a2234ec6cd
products:
  - Marketing Cloud Engagement APIs and Programmatic Languages
  - Marketing Cloud
---
# SetCookie

## Overview

Sets the name and value of the specified session cookie

**note:** When working with cookies, ensure the user experience complies with the protections of a user’s jurisdiction.

Compliance with privacy protections for cookies can include multiple strategies:

- Ensuring that a cookie notice is provided, and recommending that users read the cookie notice.
- Ensuring consistency between your cookie consent language and Salesforce’s privacy notices and policies.
- Asking the user for consent to use of cookies, for each category of cookie (first or third-party). For example:
  - Consent to Salesforce (first-party) cookies that validate user identity are critical to use of the site. But, consent for them can't be taken to imply consent to third-party cookies.
  - Consent to Salesforce partners' (third-party) analytics cookies must be acquired and tracked separately from consent to first-party cookies.
- Asking in a way that ensures the validity of a user’s active and explicit consent:
  - Avoid pre-set, or checked, checkboxes for compliance.
  - Don't construe that merely continuing to use the web service is consent.
- Allowing the user to withdraw their consent at any time, and for each category of cookie, depending on the cookie's purpose and origin (1st or 3rd party cookies).
- Periodically reminding the user that they consented to cookies, as well as what cookies they consented to.
- Not allowing cookie respawning without again collecting validated user consent.

This list is a start, but isn't exhaustive. Place cookie consent high in your list of functionalities to implement.

### Syntax

SetCookie(1, 2, 3, 4)

### Function Properties

<!--complex table-->

| Ordinal | Type     |              | Description                                                |
| ------- | -------- | ------------ | ---------------------------------------------------------- |
| **1**   | string   | **Required** | Session cookie name                                        |
| **2**   | string   | **Required** | Session cookie value                                       |
| **3**   | datetime |              | Date and time value indicating cookie expiration           |
| **4**   | Boolean  |              | Indicates whether cookie works with only HTTPS connections |

## Example

```
<script runat=server>
     Platform.Response.SetCookie("cookieName","cookieValue","2015-12-31T14:00:00.999Z",true);
</script>
```
