ZF2 get $_SESSION

593 Views Asked by At

I'm setting $_SESSION in a part of my application which is not routed by Zend. (myhost.local/example.php -> set $_SESSION['user'])

Now I want to access the $_SESSION['user'] in my Zend application. (myhost.local/newgeniuszend/index -> cant get the $_SESSION['user'])

What can I do?

1

There are 1 best solutions below

0
Wilt On

In Zend Framework you should not interact with the php $_SESSION global directly. Instead you should use the session tools that are shipped with ZF2 in the zend-session module. For session management there is a so called session-manager (Zend\Session\SessionManager).

Refer to the official ZF2 documentation here.

There are a lot of questions and answers about how to handle sessions in Zend Framework 2 on stackoverflow. If you search through those posts you probably will get answers to all your questions related to this topic.