You are here

public static function SmartIp::setSession in Smart IP 8.2

Same name and namespace in other branches
  1. 8.4 src/SmartIp.php \Drupal\smart_ip\SmartIp::setSession()
  2. 8.3 src/SmartIp.php \Drupal\smart_ip\SmartIp::setSession()

Write session variable.

Parameters

string $key: The session variable to write. Pass 'smart_ip' to write the smart_ip data.

mixed $value: The value of session variable.

1 call to SmartIp::setSession()
SmartIpLocation::save in src/SmartIpLocation.php
Saves the Smart IP location data to user data and session (for anonymous, saves to session only).

File

src/SmartIp.php, line 74
Contains \Drupal\smart_ip\SmartIp.

Class

SmartIp
Smart IP static basic methods wrapper.

Namespace

Drupal\smart_ip

Code

public static function setSession($key, $value) {
  if (\Drupal::moduleHandler()
    ->moduleExists('session_cache')) {
    session_cache_set($key, $value);
  }
  else {

    /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
    $session = \Drupal::service('session');
    $session
      ->set($key, $value);
  }
}