Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjc authored Jul 27, 2023
1 parent b8f9fdb commit 8b39431
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/services/GeoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public function location()

if ($cookie) {
// Cookie already exists, so set the location as the cookie value and set 'cached' to true to show that the cookie already existed
$location = $cookie->value;
$location = @unserialize($cookie->value);
if ($location === false) {
$location = $cookie->value;
}
$location->cached = true;

return $location;
Expand Down Expand Up @@ -175,7 +178,7 @@ public function getLocation($settings, $ipAddress)

$cookies->add(new \yii\web\Cookie([
'name' => $settings->cookieName,
'value' => $location,
'value' => serialize($location),
// current timestamp + (cookieDuration setting in hours x number of seconds in an hour)
'expire' => time() + ($settings->cookieDuration * 3600)
]));
Expand Down

0 comments on commit 8b39431

Please sign in to comment.