Laravel中未加密的cookie

Jim*_*oto 5 laravel laravel-5 laravel-5.1

我需要阅读我的Laravel应用程序设置的JS中的cookie.有没有办法在Laravel中执行此操作(而不是直接通过PHP设置它)而不重写类?

Mik*_*étt 25

查看EncryptCookies中间件 - 这允许您设置例外; 也就是说,不加密的cookie.

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'
    ];
}
Run Code Online (Sandbox Code Playgroud)