This paper analyzes the usage of SYMFONY2 session. Share to everyone for your reference, as follows:
Symfony from the method with the session, previous old version 2.2 and previous session usage is
$session = $this->getrequest ()->getsession (), $session->set (' foo ', ' Bar '), $foobar = $session->get (' Foobar ');
Later Symfony2.3 began to $this->getrequest () method was discarded, the session's use of the method becomes
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 ());}
Permanent address of this article:http://blog.it985.com/13586.html
This article is from IT985 blog, please indicate the source and corresponding link when reproduced.
Read more about PHP framework related content Readers can view this site: "PHP Excellent Development Framework Summary", "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "Yii framework Introduction and common skills Summary" and " thinkphp Getting Started Tutorial "
It is hoped that this article is helpful to the PHP program design based on Symfony framework.