You are here

function smart_ip_session_get in Smart IP 7.2

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

Read session variable.

Parameters

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

bool $locate: (optional) If the key is 'smart_ip' and the data is not set, whether to trigger a location lookup as fallback. Defaults to TRUE

mixed $default: (optional) Default value if the session variable is not set.

Return value

mixed The session variable value.

24 calls to smart_ip_session_get()
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.
smart_ip_addressfield_default_values_alter in ./smart_ip.module
Implements hook_addressfield_default_values_alter(). Allows modules to alter the default values for an address field.

... See full list

File

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

Code

function smart_ip_session_get($key, $locate = TRUE, $default = NULL) {
  if ($key == 'smart_ip' && $locate) {
    smart_ip_update_user_location();
  }
  if (module_exists('session_cache')) {
    $smart_ip_session = session_cache_get($key);
  }
  else {
    $smart_ip_session = isset($_SESSION) && isset($_SESSION[$key]) ? $_SESSION[$key] : NULL;
  }
  if ($smart_ip_session === NULL) {
    $smart_ip_session = $default;
  }
  return $smart_ip_session;
}