Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unencrypted cookie in Laravel

I need to read a cookie in JS set by my Laravel app. Is there a way to do this in Laravel (as opposed to setting it directly through PHP) without overriding classes?

like image 764
Jimmy Zoto Avatar asked Jan 27 '16 05:01

Jimmy Zoto


People also ask

Are cookies encrypted in laravel?

Since all Laravel cookies are encrypted and signed, cookie values are typically considered safe from client tampering.

How do you decrypt cookies?

Decrypt the cookie and check the digest: Decrypt de key of the cookie: do Base64 decoding, then decrypt it using your institution's private RSA key. Decrypt the data using the decrypted AES key. Check the digest using secutix public certificate. The following example in java will show you how to proceed.

How does laravel compare passwords?

2 ways: 1. $hashedPassword = User::find(1)->password; if (Hash::check('plain-text-password', $hashedPassword)) { // The passwords match... } $hashedPassword = User::find(1)->password; if (Hash::make('plain-text-password') === $hashedPassword) { // The passwords match... }


1 Answers

See the EncryptCookies Middleware - this allows you to set the exceptions; that is, cookies that are not to be encrypted.

namespace App\Http\Middleware;

use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;

class EncryptCookies extends BaseEncrypter
{
    /**
     * The names of the cookies that should not be encrypted.
     *
     * @var array
     */
    protected $except = [
        'my_cookie'
    ];
}
like image 57
Mike Rockétt Avatar answered Nov 16 '22 00:11

Mike Rockétt