Laravel 中未加密的 cookie
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35029385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unencrypted cookie in Laravel
提问by Jimmy Zoto
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?
我需要在我的 Laravel 应用程序设置的 JS 中读取 cookie。有没有办法在 Laravel 中做到这一点(而不是直接通过 PHP 设置)而不覆盖类?
回答by Mike Rockétt
See the EncryptCookies
Middleware - this allows you to set the exceptions; that is, cookies that are not to be encrypted.
查看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'
];
}