Still "new" to Laravel and encountered a unclear situation.
According to this previous S.O. post Laravel - How decrypt value of cookie, Laravel does automatically decrypt the value of a cookie when using the Cookie::get('my_cookie')
command. But in my case it doesn't. I have to use the \Illuminate\Contracts\Encryption\Encrypter
class to specifically decrypt the cookie as below.
$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$encrypter->decrypt(Cookie::get('my_cookie'))
It also mention I may need this in case I did encrypt it somewhere else. All I did to create the cookie, was invoke the Cookie::queue('my_cookie', 'blah blah', 1000)
command.
Any thought on why I may be forced to use this Encrypter
class to read the cookie value?
Thx,
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire