Get stored Zend_Auth data from outside the zend pr

2019-08-31 11:23发布

I'm working on a Zend project where I need to include another project, which isn't using ZF. This other project is stored in the public directory in the folder of the zend project.

For this other project I need the logindata from the zend project (zend auth is used for this). There are 2 ways to accomplish this i think.

  1. Just get the stored login sessionvariable. But where/what variable?
  2. Or try to get the data with zend methodes in the other project. But how? Without changing the structure of this other project.

Or maybe (probably) there's an other/better solution?!

Hope it's clear. Tnx

2条回答
叼着烟拽天下
2楼-- · 2019-08-31 12:16

The login data is in SESSION variable. But we can't access the session data directly outside the project, because the SESSION contain some Zend objects. When we start the session it race an error __PHP_Incomplete_Class has no unserializer. To over come this add the code in starting of the page.

function __autoload($class) { // required files load automatically
  require_once "pathToZendProjectDirectory/PathToZendLibrary/$class.php";
}
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-08-31 12:21
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$authNamespace->user = "myusername";

Just include pathToZendProjectDirectory\Zend\Session.php from your 'nonzend` project

查看更多
登录 后发表回答