最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Symfony2 session学习笔记
时间:2015-08-29 编辑:简简单单 来源:一聚教程网
以前老版本2.2及以前的session用法是
$session = $this->getRequest()->getSession(); $session->set('foo', 'bar'); $foobar = $session->get('foobar');
后来Symfony2.3开始$this->getRequest()方法被废弃,session的使用方法就变成了
use Symfony\Component\HttpFoundation\Request; 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()); }
-
上一个: php正则匹配字符串中js文件例子
-
下一个: PHP生成唯一订单号的6种方法
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24