Unencrypted cookie in Laravel

时光怂恿深爱的人放手 提交于 2019-12-18 06:14: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:


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'
    ];
}


来源:https://stackoverflow.com/questions/35029385/unencrypted-cookie-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!