You are here

function _bakery_bake_chocolatechip_cookie in Bakery Single Sign-On System 7.4

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

Create a new cookie for identification

3 calls to _bakery_bake_chocolatechip_cookie()
bakery_user_login in ./bakery.module
Implements hook_user_login().
bakery_user_update in ./bakery.module
Implements hook_user_update().
_bakery_taste_chocolatechip_cookie in ./bakery.module
Test identification cookie

File

./bakery.module, line 690

Code

function _bakery_bake_chocolatechip_cookie($username, $mail, $init) {
  $key = variable_get('bakery_key', '');
  if (!empty($key)) {
    $claims = array(
      'mail' => $mail,
      'init' => $init,
      'master' => variable_get('bakery_is_master', 0),
    );
    $type = _bakery_cookie_name('CHOCOLATECHIP');
    $now = $_SERVER['REQUEST_TIME'];
    $expiration = variable_get('bakery_freshness', '3600') > 0 ? $now + variable_get('bakery_freshness', '3600') : '0';
    $token = bakery_bake_data($username, $type, $expiration, $claims);

    // Allow cookies to expire when the browser closes.
    setcookie($type, $token, $expiration, '/', variable_get('bakery_domain', ''), TRUE, TRUE);
  }
}