function _ip_geoloc_set_location_on_context_session in IP Geolocation Views & Maps 7
Copy attributes from the supplied location to the context session.
Parameters
array $location: Array containing country_code, locality, postal_code and possibly more
1 call to _ip_geoloc_set_location_on_context_session()
- _ip_geoloc_set_session_value in ./
ip_geoloc.session.inc - Set a value to the user's SESSION.
File
- ./
ip_geoloc.session.inc, line 67 - ip_geoloc.session.inc
Code
function _ip_geoloc_set_location_on_context_session($location) {
// context_session does not support session_cache, can only use $_SESSION.
// Note that context_session only offers boolean support: it sets a
// context based on the fact whether a key is present or not. So we have
// to fake name|value pairs.
foreach (array(
'country_code',
'administrative_area_level_1',
'locality',
'postal_code',
) as $key) {
// Clear out old values
foreach ($_SESSION as $session_key => $val) {
if (strpos($session_key, "ip_geoloc:location.{$key}=") === 0) {
unset($_SESSION[$session_key]);
}
}
if (!empty($location[$key])) {
$_SESSION["ip_geoloc:location.{$key}=" . $location[$key]] = TRUE;
// If and when Context Session accepts name|value pairs we can go:
//$_SESSION["ip_geoloc:location.$key"] = $val;
}
}
}