<< Back to Dashboard

Contents

Exploring the ClientStorage Plugin

Overview

Client Storage plugin. It provides the user with a mechanism for permanent data storage using the client scope and WDDX.

clearAll

Clear the entire coldbox client storage

Returns

Examples

// Clear the entire client storage
getPlugin("ClientStorage").clearAll();

exists

Checks wether the permanent variable exists.

Returns

Arguments

Key Type Required Default Description
name string Yes --- The variable name to retrieve.

Examples

if ( getPlugin("ClientStorage").exists("userData") ){
  // use the data
}

getVar

Get a new permanent variable. If the variable does not exist. The method returns blank.

Returns

Arguments

Key Type Required Default Description
name string Yes --- The variable name to retrieve.
default any No The default value to set. If not used, a blank is returned.

Examples

// No default
var userData = getPlugin("ClientStorage").getVar("userData");

// With Default
var data= getPlugin("ClientStorage").getVar("userData", structNew() );

setVar

Set a new permanent variable.

Returns

Arguments

Key Type Required Default Description
name string Yes --- The name of the variable.
value any Yes --- The value to set in the variable.

Examples

// Prepare data, can be simple or complex
userData = {
  name = "Luis Majano",
  created = now(),
  nicknames = ["Captain Awesome", "Pio"],
  awesomeLevel = "high"
};
getPlugin("ClientStorage").setVar("userData", userData);

getStorage

Get the entire storage scope structure

Returns

Examples

var clientStorage = getPlugin("ClientStorage").getStorage();

deleteVar

Tries to delete a permanent client var.

Returns

Arguments

Key Type Required Default Description
name string Yes --- The variable name to retrieve.

Examples

getPlugin("ClientStorage").deleteVar("userData");