最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Symfony2 session学习笔记
时间:2022-06-25 02:48:33 编辑:袖梨 来源:一聚教程网
以前老版本2.2及以前的session用法是
$session = $this->getRequest()->getSession(); $session->set('foo', 'bar'); $foobar = $session->get('foobar');
后来Symfony2.3开始$this->getRequest()方法被废弃,session的使用方法就变成了
use SymfonyComponentHttpFoundationRequest; public function indexAction(Request $request) { $session = $request->getSession(); // store an attribute for reuse during a later user request $session->set('foo', 'bar'); // get the attribute set by another controller in another request $foobar = $session->get('foobar'); // use a default value if the attribute doesn't exist $filters = $session->get('filters', array()); }
相关文章
- 剑星信息14怎么获取 信息14获取方式分享 07-17
- 剑星信息13在哪 信息13获取位置分享 07-17
- 剑星信息12如何获取 信息12获取方法介绍 07-17
- 十大虚拟币交易平台app排行榜 以太坊浏览器 07-17
- 沙丘觉醒阿特里迪斯间谍中的间谍任务怎么做 间谍任务攻略 07-17
- 沙丘觉醒阿特里迪斯新入教者任务怎么做 任务攻略 07-17