A set of utils to get, set and remove cookie data.

Methods

(inner) get(name) → {null|string}

Gets a specific cookie.

Parameters:
NameTypeDescription
namestring

The cookie to get.

Since
  • 1.0.0
Returns:

Returns a cookie or null if none found for name.

Type: 
null | string
Example
import { cookieStorage } from "@gravityforms/utils";

function Example() {
    console.log( cookieStorage.get( 'my-cookie' ) );
};

(inner) remove(name) → {void}

Removes a cookie.

Parameters:
NameTypeDescription
namestring

The cookie name.

Since
  • 1.0.0
Returns:
Type: 
void
Example
import { cookieStorage } from "@gravityforms/utils";

function Example() {
		cookieStorage.remove( 'my-cookie' );
};

(inner) set(name, value, daysToExpire, updateExistingValue) → {null|string}

Creates and sets a cookie.

Parameters:
NameTypeDescription
namestring

The cookie name.

valuestring

The cookie value.

daysToExpirenull | number | string

The number of days until cookie should expire. If not set, will expire at the end of the user sessions.

updateExistingValueboolean

Whether or not to update the existing cookie value to include the new value. Can be helpful for keeping cookie count lower for the browser.

Since
  • 1.0.0
Returns:

Returns a cookie or null if none found for name.

Type: 
null | string
Example
import { cookieStorage } from "@gravityforms/utils";

function Example() {
     const cookieValue = uniqueId( 'gform-alert' );
		cookieStorage.set( this.options.cookieName, cookieValue, 1, true );
};