You are here

function drupalchat_user_logout in DrupalChat 7.2

Same name and namespace in other branches
  1. 8 drupalchat.module \drupalchat_user_logout()
  2. 7 drupalchat.module \drupalchat_user_logout()

File

./drupalchat.module, line 1452
Module code for DrupalChat.

Code

function drupalchat_user_logout($account) {
  if (check_plain(variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX)) == DRUPALCHAT_COMMERCIAL) {
    setcookie("iflychat_key", "", time() - 3600, "/");
    setcookie("iflychat_css", "", time() - 3600, "/");
    setcookie("iflychat_time", "", time() - 3600, "/");
  }

  //delete token start
  $data = json_encode(array(
    'api_key' => check_plain(variable_get('drupalchat_external_api_key', NULL)),
  ));
  $options = array(
    'method' => 'POST',
    'data' => $data,
    'timeout' => 15,
    'headers' => array(
      'Content-Type' => 'application/json',
    ),
  );
  $result = drupal_http_request('https://api.iflychat.com/api/1.1/token/' . $_SESSION['token'] . '/delete', $options);

  //delete token end
  unset($_SESSION['token']);
  return $result;
}