function _drupal_cookie_params

Process the params for cookies. This emulates support for the SameSite attribute in earlier versions of PHP, and allows the value of that attribute to be overridden.

Parameters

$options: An associative array which may have any of the keys expires, path, domain, secure, httponly, samesite.

Return value

An associative array which may have any of the keys expires, path, domain, secure, httponly, and samesite.

2 calls to _drupal_cookie_params()
drupal_session_start in includes/session.inc
Starts a session forcefully, preserving already set session data.
drupal_setcookie in includes/bootstrap.inc
Drupal's wrapper around PHP's setcookie() function.

File

includes/bootstrap.inc, line 3998

Code

function _drupal_cookie_params($options) {
    $options['samesite'] = _drupal_samesite_cookie($options);
    if (\PHP_VERSION_ID < 70300) {
        // Emulate SameSite support in older PHP versions.
        if (!empty($options['samesite'])) {
            // Ensure the SameSite attribute is only added once.
            if (!preg_match('/SameSite=/i', $options['path'])) {
                $options['path'] .= '; SameSite=' . $options['samesite'];
            }
        }
    }
    return $options;
}

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