You are here

function smart_ip_session_set in Smart IP 6.2

Same name and namespace in other branches
  1. 6 smart_ip.module \smart_ip_session_set()
  2. 7.2 smart_ip.module \smart_ip_session_set()
  3. 7 smart_ip.module \smart_ip_session_set()

Write session variable.

Parameters

string $key: Key of session variable.

mixed $value: Value of session variable to be set.

9 calls to smart_ip_session_set()
device_geolocation_check_geolocation_attempt in modules/device_geolocation/device_geolocation.module
Check for Geolocation attempt.
device_geolocation_contents in modules/device_geolocation/device_geolocation.module
Device geolocation block content function.
device_geolocation_detector_ajax in modules/device_geolocation/device_geolocation.module
Google Geocoding ajax callback function data recipient.
device_geolocation_get_coordinates in modules/device_geolocation/device_geolocation.module
Get Visitor's coordinates.
device_geolocation_presave in modules/device_geolocation/device_geolocation.module
Implements hook_user_presave().

... See full list

File

./smart_ip.module, line 1154
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_session_set($key, $value) {
  $eu_visitor_dont_save = FALSE;
  if ($key == 'smart_ip') {
    smart_ip_update_fields($value['location']);
    $location = $value['location'];

    // Determine if saving location details of visitor from EU countries are
    // permitted.
    if (isset($location['is_gdpr_country'])) {
      $eu_visitor_dont_save = variable_get('smart_ip_eu_visitor_dont_save', FALSE) && $location['is_gdpr_country'];
    }
  }

  // Check if the user permitted to share location
  $share_location = smart_ip_session_get('smart_ip_user_share_location_permitted', FALSE, TRUE);
  if ($key != 'smart_ip' || $key == 'smart_ip' && $share_location && !$eu_visitor_dont_save) {
    if (module_exists('session_cache')) {
      session_cache_set($key, $value);
    }
    else {
      $_SESSION[$key] = $value;
    }
  }
}