function _bakery_validate_cookie in Bakery Single Sign-On System 6
Same name and namespace in other branches
- 6.2 bakery.module \_bakery_validate_cookie()
- 7.4 bakery.module \_bakery_validate_cookie()
- 7.2 bakery.module \_bakery_validate_cookie()
Function to validate cookies
Parameters
$type (string) CHOCOLATECHIP or OATMEAL, default CHOCOLATECHIP:
Return value
the validated and decrypted cookie in an array or FALSE
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 - _bakery_taste_chocolatechip_cookie in ./
bakery.module - Test identification cookie
- _bakery_taste_oatmeal_cookie in ./
bakery.module - Test redirect cookie
File
- ./
bakery.module, line 358
Code
function _bakery_validate_cookie($type = 'CHOCOLATECHIP') {
$key = variable_get('bakery_key', '');
if (!isset($_COOKIE[$type]) || !$key || !variable_get('bakery_domain', '')) {
return;
}
$cookie = unserialize(bakery_mix($_COOKIE[$type], 0));
$signature = hash_hmac('sha256', $cookie['name'] . '/' . $cookie['mail'] . '/' . $cookie['timestamp'], $key);
$valid = FALSE;
if ($signature == $cookie['signature'] && $cookie['timestamp'] + variable_get('bakery_freshness', '3600') >= $_SERVER['REQUEST_TIME']) {
$valid = TRUE;
}
return $valid ? $cookie : $valid;
}