1

在 Zend Framework 2 中开发了一个项目并集成了concrete5,我如何在使用zend Framework 2 创建的concrete5 会话中访问?

4

1 回答 1

0

If you have created your ZF2 session within a user namespace, for example, you will be able to access it like this: $_SESSION['user']['username']. Below is a more complete example.

// Storing session data within Zend Framework 2
$session = new \Zend\Session\Container('user');
$session->username = 'Andy0708';

// Accessing session data within concrete5
$username = $_SESSION['user']['username'];

Alternatively, you should be able to simply use the Zend\Session component within concrete5. Although one of the goals of Zend Framework 2 is to avoid dependencies, I have not checked if there are any dependencies to the Zend\Session component. Otherwise, having autoloading in place, this would not be a problem. It has been a while since I have worked with concrete5, so I am unable to provide you with details of how to handle autoloading and such in concrete5, but since you have already integrated concrete5, you should have handled this already. So, you should also be able to do something like this if you prefer the ZF2 way:

// Assuming that autoloading is in place
$session = new \Zend\Session\Container('user');
$username = $session->username;
于 2013-07-15T17:33:31.737 回答