Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NativeSessionStorage.php

function NativeSessionStorage::setOptions

Sets session.* ini variables.

For convenience we omit 'session.' from the beginning of the keys. Explicitly ignores other ini keys.

Parameters

array $options Session ini directives [key => value]:

See also

https://php.net/session.configuration

2 calls to NativeSessionStorage::setOptions()
NativeSessionStorage::__construct in vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
Depending on how you want the storage driver to behave you probably want to override this constructor entirely.
SessionManager::start in core/lib/Drupal/Core/Session/SessionManager.php
Starts the session.

File

vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php, line 316

Class

NativeSessionStorage
This provides a base class for session attribute storage.

Namespace

Symfony\Component\HttpFoundation\Session\Storage

Code

public function setOptions(array $options) : void {
    if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
        return;
    }
    $validOptions = array_flip([
        'cache_expire',
        'cache_limiter',
        'cookie_domain',
        'cookie_httponly',
        'cookie_lifetime',
        'cookie_path',
        'cookie_secure',
        'cookie_samesite',
        'gc_divisor',
        'gc_maxlifetime',
        'gc_probability',
        'lazy_write',
        'name',
        'referer_check',
        'serialize_handler',
        'use_strict_mode',
        'use_cookies',
        'use_only_cookies',
        'use_trans_sid',
        'sid_length',
        'sid_bits_per_character',
        'trans_sid_hosts',
        'trans_sid_tags',
    ]);
    foreach ($options as $key => $value) {
        if (\in_array($key, [
            'referer_check',
            'use_only_cookies',
            'use_trans_sid',
            'trans_sid_hosts',
            'trans_sid_tags',
            'sid_length',
            'sid_bits_per_character',
        ], true)) {
            trigger_deprecation('symfony/http-foundation', '7.2', 'NativeSessionStorage\'s "%s" option is deprecated and will be ignored in Symfony 8.0.', $key);
        }
        if (isset($validOptions[$key])) {
            if ('cookie_secure' === $key && 'auto' === $value) {
                continue;
            }
            ini_set('session.' . $key, $value);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal