'How to read laravel_session cookies saved in cookie memory of browser in client side?

I have an laravel and angular based application, I would like to read cookies from client to server side, But i can't read it. So can any one tell me how could I read the cookies.



Solution 1:[1]

By default, Laravel enables Browser's HTTP-Only feature, meaning the cookie is not accessible from JavaScript.

But that can be turned off,
by changing the default-value to false in the config/session.php file:

/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/

'http_only' => true,

Also note that laravel cookies are encrypted and decrypted on the fly by the application. Even if you read the cookie, it would be the encrypted value. If you need to access and modify certain cookies without encryption, then you need to add those cookies to the encryption except list.

You can add the cookies to skip encryption in the file app/Http/Middleware/EncryptCookies.php

protected $except = [
    //
];

Solution 2:[2]

By default laravel_session cookie is HTTP_ONLY so you can't manipulate them with js. But you can change this flag in your_project\config\session.php by adding

'http_only' => false

Solution 3:[3]

I've just posted an answer to a related question which I think may also be relevant, as I believe you're dealing with the client cookies in server here: How to work with cookies in Laravel 5.2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Top-Master
Solution 2 Alex Slipknot
Solution 3 D0mski