Skip to content

Commit 8467e58

Browse files
committed
Add option to check raw cookie value instead of encrypted Laravel cookie
1 parent 79240d6 commit 8467e58

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config/localized-routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
*/
7272
'cookie_minutes' => 60 * 24 * 365, // 1 year
7373

74+
/**
75+
* Check raw cookie with $_COOKIE due to the default encryption by Laravel.
76+
*/
77+
'check_raw_cookie' => false,
78+
7479
/**
7580
* The detectors to use to find a matching locale.
7681
* These will be executed in the order that they are added to the array!

src/Middleware/Detectors/CookieDetector.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class CookieDetector implements Detector
1515
public function detect()
1616
{
1717
$key = Config::get('localized-routes.cookie_name');
18-
19-
return Cookie::get($key);
18+
if (Config::get('localized-routes.check_raw_cookie')) {
19+
return $_COOKIE[$key] ?? null;
20+
} else {
21+
return Cookie::get($key);
22+
}
2023
}
2124
}

0 commit comments

Comments
 (0)