public function IpGeoLocSession::setSessionValue in IP Geolocation Views & Maps 8
Set a value to the user's SESSION.
Parameters
string $name: if FALSE all IPGV&M session variables are deleted; if NULL the array of all IPGV&M session variables is returned.
mixed $value: The value to set.
Return value
mixed The requested or all session variables from ip_geoloc
1 call to IpGeoLocSession::setSessionValue()
- IpGeoLocSession::getSessionValue in src/
Services/ IpGeoLocSession.php  - Get a value from the user's SESSION or all values, if no name is specified.
 
File
- src/
Services/ IpGeoLocSession.php, line 35  
Class
- IpGeoLocSession
 - Class DrupaliseMe.
 
Namespace
Drupal\ip_geoloc\ServicesCode
public function setSessionValue($name, $value = NULL) {
  if (!$this->moduleHandler
    ->moduleExists('session_cache')) {
    if ($name === FALSE) {
      unset($_SESSION['ip_geoloc']);
    }
    elseif (isset($name)) {
      $_SESSION['ip_geoloc'][$name] = $value;
    }
    return isset($_SESSION) && isset($_SESSION['ip_geoloc']) ? $_SESSION['ip_geoloc'] : NULL;
  }
  if ($name === FALSE) {
    session_cache_set('ip_geoloc', NULL);
    return NULL;
  }
  // Efficiency: for multiple get's during the same request avoid having to go
  // to the storage mechanism each time.
  $variables =& drupal_static(__FUNCTION__, []);
  if (empty($variables)) {
    $variables = session_cache_get('ip_geoloc');
  }
  if (isset($name)) {
    $variables[$name] = $value;
    session_cache_set('ip_geoloc', $variables);
  }
  return $variables;
}