Home > database >  How to decrypt Laravel cookies in Vue
How to decrypt Laravel cookies in Vue

Time:10-31

I attached cookies to the responses. enter image description here

My Laravel code.

return response('Hello World')->cookie('myCookieName', 'MyValue', 0);

Vue using this package https://www.npmjs.com/package/vue-cookies

console.log(this.$cookie.get('myCookieName'))

console result eyJ1c2VybmFtZSI6Inl1cmlpIiwiZnVsbF9..... I'm expected the real value of my cookie. MyValue

How to decrypt or decode the value of cookies to get the real value in Vue?

CodePudding user response:

The App\Http\Middleware\EncryptCookies middleware in Laravel allows you to set exceptions. Example:

/**
 * The names of the cookies that should not be encrypted.
 *
 * @var array
 */
protected $except = [
    'cookie_name',
];

For more info checkout the documentation.

  • Related