zendframework / zf2-documentation

Zend Framework 2 documentation sources
BSD 3-Clause "New" or "Revised" License
190 stars 569 forks source link

Third party session sharing #993

Open cedricus opened 11 years ago

cedricus commented 11 years ago

Hi!

I'am using third party software and the provided source code on official documentation (see: http://framework.zend.com/manual/2.2/en/modules/zend.session.manager.html) does not work :

$cwd = getcwd();
chdir('/path/to/zf2-application');
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
chdir($cwd);
session_start();

But this works:

session_start();
chdir(dirname(__DIR__));
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php')->run();

With the second solution I'am able to get the software session in my controllers.

$sessionContainer = new Container('session');
$sessionContainer->content = $_SESSION;
samsonasik commented 11 years ago

the doc is for the case when you're running non ZF session component on third party software, for example, you run a project with wordpress cms, and need ZF project run at the same time, so, at other third party software, at initial state, you need to get the ZF.