问题
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.
- Just get the stored login sessionvariable. But where/what variable?
- 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