1 bootstrap.inc state_set($name, $value)

Sets a persistent state value.

Parameters

$name: The name of the state to set.

$value: The value to set. Complex data types will be serialized upon storage.

See also

state_get()

state_del()

File

core/includes/bootstrap.inc, line 1369
Functions that need to be loaded on every Backdrop request.

Code

function state_set($name, $value) {
  $states = &backdrop_static('states');
  db_merge('state')
    ->key(array('name' => $name))
    ->fields(array('value' => serialize($value)))
    ->execute();
  cache('cache')->delete('states');
  if (isset($states)) {
    $states[$name] = $value;
  }
}