function user_cookie_save

Same name in other branches
  1. 7.x modules/user/user.module \user_cookie_save()
  2. 9 core/modules/user/user.module \user_cookie_save()
  3. 8.9.x core/modules/user/user.module \user_cookie_save()
  4. 11.x core/modules/user/user.module \user_cookie_save()

Saves visitor information as a cookie so it can be reused.

Parameters

array $values: An array of key/value pairs to be saved into a cookie.

1 call to user_cookie_save()
SystemController::compactPage in core/modules/system/src/Controller/SystemController.php
Sets whether the admin menu is in compact mode or not.

File

core/modules/user/user.module, line 1147

Code

function user_cookie_save(array $values) {
    $request_time = \Drupal::time()->getRequestTime();
    foreach ($values as $field => $value) {
        // Set cookie for 365 days.
        setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), $request_time + 31536000, '/');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.