public static function SmartIp::getSession in Smart IP 8.4
Same name and namespace in other branches
- 8.2 src/SmartIp.php \Drupal\smart_ip\SmartIp::getSession()
- 8.3 src/SmartIp.php \Drupal\smart_ip\SmartIp::getSession()
Read session variable.
Parameters
string $key: The session variable to read. Pass 'smart_ip' to read the smart_ip data.
mixed $default: Default value if the session variable is not set.
Return value
array Session value.
5 calls to SmartIp::getSession()
- 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.
- SmartIp::updateUserLocation in src/
SmartIp.php - Update user's location only if the IP address stored in session is not the same as the IP address detected by the server or debug mode IP.
- SmartIpLocation::getData in src/
SmartIpLocation.php - Gets all the Smart IP location data.
- SmartIpLocation::save in src/
SmartIpLocation.php - Saves the Smart IP location data to user data and session (for anonymous, saves to session only).
File
- src/
SmartIp.php, line 168 - Contains \Drupal\smart_ip\SmartIp.
Class
- SmartIp
- Smart IP static basic methods wrapper.
Namespace
Drupal\smart_ipCode
public static function getSession($key, $default = NULL) {
if (\Drupal::moduleHandler()
->moduleExists('session_cache')) {
$smartIpSession = session_cache_get($key);
}
else {
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = \Drupal::service('session');
// Make sure session is started before calling any functions.
if ($session
->isStarted()) {
$smartIpSession = $session
->get($key);
}
else {
$smartIpSession = $default;
}
}
if ($smartIpSession === NULL) {
$smartIpSession = $default;
}
return $smartIpSession;
}