---
schema_version: "1"
id: 91b37320f8a42dde18598eb11c8e0f363ecfd236fead88cb45b24182e9ee175c
title: setCookies(cookies)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_setCookies.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setCookies.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c16dffeafba26c01bdb13335c507d21f1b085535eadc2e7fe02da2b870fdda83
description: Creates a list of cookie objects. Used in conjunction with the Cookie class.
---
# setCookies(cookies)

Creates a list of cookie objects. Used in conjunction with the Cookie class.

## Signature

public Void setCookies(Cookie\[\] cookies)

## Parameters

- **cookies**: Type: [System.Cookie](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_sites_cookie.htm#apex_classes_sites_cookie "The Cookie class lets you access cookies for your Salesforce site using Apex.")\[\]

## Return Value

Type: Void

## Usage

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

- Cookie names and values set in Apex are URL encoded, that is, characters such as @ are replaced with a percent sign and their hexadecimal representation.
- The setCookies method adds the prefix “apex\_\_” to the cookie names.
- Setting a cookie's value to null sends a cookie with an empty string value instead of setting an expired attribute.
- After you create a cookie, the properties of the cookie can't be changed.
- Be careful when storing sensitive information in cookies. Pages are cached regardless of a cookie value. If you use a cookie value to generate dynamic content, you should disable page caching. For more information, see [Configure Site Caching](https://help.salesforce.com/articleView?id=platform.sites_caching.htm&type=5&language=en_US) in Salesforce Help.