Unencrypted cookie in Laravel

后端 未结 1 1014
走了就别回头了
走了就别回头了 2020-12-19 02:09

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?

相关标签:
1条回答
  • 2020-12-19 02:58

    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'
        ];
    }
    
    0 讨论(0)
提交回复
热议问题