You are here

public static function SmartIp::setSession in Smart IP 8.4

Same name and namespace in other branches
  1. 8.2 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.

6 calls to SmartIp::setSession()
DeviceGeolocation::isNeedUpdate in modules/device_geolocation/src/DeviceGeolocation.php
Check if user's location needs update via client side.
DeviceGeolocationController::saveLocation in modules/device_geolocation/src/Controller/DeviceGeolocationController.php
Google Geocoding ajax callback function data handler.
device_geolocation_entity_insert in modules/device_geolocation/device_geolocation.module
Implements hook_entity_insert().
device_geolocation_user_login in modules/device_geolocation/device_geolocation.module
Implements hook_user_login().
SmartIpLocation::delete in src/SmartIpLocation.php
Deletes the Smart IP location data in user data and session.

... See full list

File

src/SmartIp.php, line 147
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);
  }
}