ode*_*ded 3 php cookies laravel-5.4
我在 laravel 5.4 中有这个功能,但我无法从 cookie 中得到任何东西。
Cookie::queue('currentLang', 'heb', 999999999);
echo $request->cookie('currentLang');
Run Code Online (Sandbox Code Playgroud)
但是我得到了一些长字符串而不是我设置的字符串。
小智 5
Laravel 有一个 cookie 助手!
/**
* Create a new cookie instance.
*
* @param string $name
* @param string $value
* @param int $minutes
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return \Symfony\Component\HttpFoundation\Cookie
*/
function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
{
$cookie = app(CookieFactory::class);
if (is_null($name)) {
return $cookie;
}
return $cookie->make($name, $value, $minutes, $path, $domain, $secure, $httpOnly);
}
Run Code Online (Sandbox Code Playgroud)
然后使用:
Cookie::get('$name')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9897 次 |
| 最近记录: |