From 79240d61716dfb04272ca0d3316637872ecebd7b Mon Sep 17 00:00:00 2001 From: kars Date: Tue, 8 Apr 2025 03:03:31 +0900 Subject: [PATCH 1/2] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 7dd0b01..5c112f0 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/opgginc/codezero-laravel-localized-routes/run-tests.yml?style=flat-square&logo=github&logoColor=white&label=tests)](https://github.com/opgginc/codezero-laravel-localized-routes/actions) [![Total Downloads](https://img.shields.io/packagist/dt/opgginc/codezero-laravel-localized-routes.svg?style=flat-square)](https://packagist.org/packages/opgginc/codezero-laravel-localized-routes) -[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R3UQ8V) - A convenient way to set up and use localized routes in a Laravel app. ## Important Note From 8467e58fbb8fa818f8a275c54c93de5d1e622059 Mon Sep 17 00:00:00 2001 From: Sangrak Choi Date: Sat, 19 Apr 2025 15:49:28 +0800 Subject: [PATCH 2/2] Add option to check raw cookie value instead of encrypted Laravel cookie --- config/localized-routes.php | 5 +++++ src/Middleware/Detectors/CookieDetector.php | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/localized-routes.php b/config/localized-routes.php index 2dd9718..3560741 100644 --- a/config/localized-routes.php +++ b/config/localized-routes.php @@ -71,6 +71,11 @@ */ 'cookie_minutes' => 60 * 24 * 365, // 1 year + /** + * Check raw cookie with $_COOKIE due to the default encryption by Laravel. + */ + 'check_raw_cookie' => false, + /** * The detectors to use to find a matching locale. * These will be executed in the order that they are added to the array! diff --git a/src/Middleware/Detectors/CookieDetector.php b/src/Middleware/Detectors/CookieDetector.php index 043ffdd..b0b2500 100644 --- a/src/Middleware/Detectors/CookieDetector.php +++ b/src/Middleware/Detectors/CookieDetector.php @@ -15,7 +15,10 @@ class CookieDetector implements Detector public function detect() { $key = Config::get('localized-routes.cookie_name'); - - return Cookie::get($key); + if (Config::get('localized-routes.check_raw_cookie')) { + return $_COOKIE[$key] ?? null; + } else { + return Cookie::get($key); + } } }