|
Client Storage plugin. It provides the user with a mechanism for permanent data storage using the client scope and WDDX.
Clear the entire coldbox client storage
// Clear the entire client storage getPlugin("ClientStorage").clearAll();
Checks wether the permanent variable exists.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
if ( getPlugin("ClientStorage").exists("userData") ){ // use the data }
Get a new permanent variable. If the variable does not exist. The method returns blank.
| 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. |
// No default var userData = getPlugin("ClientStorage").getVar("userData"); // With Default var data= getPlugin("ClientStorage").getVar("userData", structNew() );
Set a new permanent variable.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The name of the variable. |
| value | any | Yes | --- | The value to set in the variable. |
// Prepare data, can be simple or complex userData = { name = "Luis Majano", created = now(), nicknames = ["Captain Awesome", "Pio"], awesomeLevel = "high" }; getPlugin("ClientStorage").setVar("userData", userData);
Get the entire storage scope structure
var clientStorage = getPlugin("ClientStorage").getStorage();
Tries to delete a permanent client var.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
getPlugin("ClientStorage").deleteVar("userData");