You are here

function _bakery_validate_cookie in Bakery Single Sign-On System 7.2

Same name and namespace in other branches
  1. 6.2 bakery.module \_bakery_validate_cookie()
  2. 6 bakery.module \_bakery_validate_cookie()
  3. 7.4 bakery.module \_bakery_validate_cookie()

Function to validate cookies.

Parameters

string $type: CHOCOLATECHIP or OATMEAL, default CHOCOLATECHIP

Return value

mixed Validated and decrypted cookie in an array, FALSE if invalid, or NULL.

4 calls to _bakery_validate_cookie()
bakery_uncrumble in ./bakery.module
Form to let users repair minor problems themselves.
bakery_uncrumble_submit in ./bakery.module
Submit handler for 'bakery_uncrumble' form.
bakery_user_logout in ./bakery.module
Implements hook_user_logout().
_bakery_taste_chocolatechip_cookie in ./bakery.module
Test identification cookie.

File

./bakery.module, line 1063
Module file for the Bakery.

Code

function _bakery_validate_cookie($type = 'CHOCOLATECHIP') {
  $key = variable_get('bakery_key', '');
  $type = _bakery_cookie_name($type);
  if (!isset($_COOKIE[$type]) || !$key || !variable_get('bakery_domain', '')) {

    // No cookie is set or site is misconfigured. Return NULL so existing
    // cookie is not deleted by bakery_eat_cookie().
    return NULL;
  }
  if (($data = bakery_validate_data($_COOKIE[$type], $type)) !== FALSE) {
    return $data;
  }
  else {
    return FALSE;
  }
}