Enables apps to store, retrieve, and delete client side data. The data is stored in the Atlassian product's localStorage, not the app's localStorage. This data cannot be seen by other apps.
This module is named "Cookie" as it originally used cookies to store data. It now uses localStorage, but the name has been kept for backwards compatibility.
Save a value to localStorage.
Name | Type | Description |
---|---|---|
name | String | The name to store the data against. |
value | String | The value to store. |
expires | Number | Optional, the number of days before expiry, defaults to 365. |
1
AP.cookie.save('my_cookie', 'my value', 1);
Get a value from localStorage (falls back to cookie for legacy support).
Name | Type | Description |
---|---|---|
name | String | The name to store the data against. |
callback | function | The callback to pass the data to. |
1 2
AP.cookie.save('my_cookie', 'my value', 1);
AP.cookie.read('my_cookie', function(value) { alert(value); });
Deletes a value from localStorage.
Name | Type | Description |
---|---|---|
name | String | The name of the data to remove. |
1 2 3
AP.cookie.save('my_cookie', 'my value', 1);
AP.cookie.read('my_cookie', function(value) { alert(value); });
AP.cookie.erase('my_cookie');
Rate this page: