You are here

function user_variable_del in User variable 6

Same name and namespace in other branches
  1. 7 user_variable.module \user_variable_del()

Remove the variable with the given name.

Parameters

$name: Variable name.

$common: If TRUE then the variable does not depend on user ID.

$uid: User ID.

$session: Session ID.

File

./user_variable.module, line 185
User variable - Creating and working with user variables.

Code

function user_variable_del($name, $common = FALSE, $uid = 0, $session = '') {
  global $user_variables_array, $user;
  if ($session === TRUE) {
    $session = session_id();
  }
  elseif ($session === FALSE) {
    $session = '';
  }
  if ($common) {
    db_query("DELETE FROM {user_variable}\n      WHERE common = 1 AND name = '%s' AND sid = '%s'", $name, $session);
    if ($session == '') {
      unset($user_variables_array['common_session'][$name]);
    }
    else {
      unset($user_variables_array['common'][$session][$name]);
    }
  }
  else {
    if (!$uid) {
      $uid = $user->uid;
    }
    db_query("DELETE FROM {user_variable}\n      WHERE common = 0 AND name = '%s' AND uid = %d AND sid = '%s'", $name, $uid, $session);
    if ($session == '') {
      unset($user_variables_array['uid_session'][$uid][$name]);
    }
    else {
      unset($user_variables_array['uid'][$uid][$session][$name]);
    }
  }
}