Symfony中的会话管理(Session management in Symfony)

我的项目中有两个控制器文件。 在第一个,LoginProfileController和LoginProfileAction函数里面,我写了$session = new Session(); $session->start(); $session = new Session(); $session->start(); 然后我需要访问其他文件中的相同会话对象。 由于symfony不支持$_SESSION变量,我不知道该怎么做。 请帮帮我。

I have two controller files in my project. In first one, LoginProfileController, and inside LoginProfileAction function, i write $session = new Session(); $session->start(); then i need to access the same session object in other file. since the symfony doesn't support $_SESSION Variable, I have no idea how to do that. Please help me.

最满意答案

Symfony Session是本机php $ _SESSION数组的包装器。 只需在需要的地方实例化新的$ session对象,您就可以访问会话数据。

看看: http : //symfony.com/doc/current/components/http_foundation/sessions.html

幕后的BTW symfony使用$ _SESSION数组。

I found a better answer from Stackover flow. This is the link for that. link

Symfony中的会话管理(Session management in Symfony)

我的项目中有两个控制器文件。 在第一个,LoginProfileController和LoginProfileAction函数里面,我写了$session = new Session(); $session->start(); $session = new Session(); $session->start(); 然后我需要访问其他文件中的相同会话对象。 由于symfony不支持$_SESSION变量,我不知道该怎么做。 请帮帮我。

I have two controller files in my project. In first one, LoginProfileController, and inside LoginProfileAction function, i write $session = new Session(); $session->start(); then i need to access the same session object in other file. since the symfony doesn't support $_SESSION Variable, I have no idea how to do that. Please help me.

最满意答案

Symfony Session是本机php $ _SESSION数组的包装器。 只需在需要的地方实例化新的$ session对象,您就可以访问会话数据。

看看: http : //symfony.com/doc/current/components/http_foundation/sessions.html

幕后的BTW symfony使用$ _SESSION数组。

I found a better answer from Stackover flow. This is the link for that. link