You are here

function _bakery_bake_chocolatechip_cookie in Bakery Single Sign-On System 6

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

Create a new cookie for identification

2 calls to _bakery_bake_chocolatechip_cookie()
bakery_user in ./bakery.module
Implementation of hook_user().
_bakery_taste_chocolatechip_cookie in ./bakery.module
Test identification cookie

File

./bakery.module, line 525

Code

function _bakery_bake_chocolatechip_cookie($name, $mail, $init) {
  $key = variable_get('bakery_key', '');
  if (!empty($key)) {
    $cookie = array();
    $cookie['name'] = $name;
    $cookie['mail'] = $mail;
    $cookie['init'] = $init;
    $cookie['master'] = variable_get('bakery_is_master', 0);
    $cookie['calories'] = 480;
    $cookie['timestamp'] = $_SERVER['REQUEST_TIME'];
    $cookie['signature'] = hash_hmac('sha256', $cookie['name'] . '/' . $cookie['mail'] . '/' . $cookie['timestamp'], $key);
    setcookie('CHOCOLATECHIP', bakery_mix(serialize($cookie), 1), $_SERVER['REQUEST_TIME'] + variable_get('bakery_freshness', '3600'), '/', variable_get('bakery_domain', ''));
  }
}