diff --git a/src/Concerns/InteractsWithCookies.php b/src/Concerns/InteractsWithCookies.php index 856d752e1..996c5653a 100644 --- a/src/Concerns/InteractsWithCookies.php +++ b/src/Concerns/InteractsWithCookies.php @@ -4,6 +4,8 @@ use DateTimeInterface; use Facebook\WebDriver\Exception\NoSuchCookieException; +use Illuminate\Cookie\CookieValuePrefix; +use Illuminate\Support\Facades\Crypt; trait InteractsWithCookies { @@ -29,7 +31,10 @@ public function cookie($name, $value = null, $expiry = null, array $options = [] } if ($cookie) { - return decrypt(rawurldecode($cookie['value']), $unserialize = false); + $decryptedValueCookieValue = decrypt(rawurldecode($cookie['value']), $unserialize = false); + $hasValuePrefix = strpos($decryptedValueCookieValue, CookieValuePrefix::create($name, Crypt::getKey())) === 0; + + return ($hasValuePrefix) ? CookieValuePrefix::remove($decryptedValueCookieValue) : $decryptedValueCookieValue; } }