Get stored Zend_Auth data from outside the zend project (in an extern non-zend-project)

跟風遠走 提交于 2020-01-06 13:52:59

问题


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


回答1:


$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$authNamespace->user = "myusername";

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




回答2:


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";
}


来源:https://stackoverflow.com/questions/6815710/get-stored-zend-auth-data-from-outside-the-zend-project-in-an-extern-non-zend-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!