最新下载
热门教程
- 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()); }
相关文章
- Coinbase在2025年加密货币峰会上公布多款新产品 06-15
- 《星之破晓》猫影幻舞技能有哪些优势 06-15
- 《雾境序列》香叶角色大全完整索引 06-15
- OM币购买步骤-2025币安交易所快速教程 06-15
- 《无限暖暖》居家风格的衣服怎么获得 06-15
- 全球十大虚拟货币交易所 虚拟币平台排行榜 06-15