How to Pass A Session Variable in Zend To Native PHP
123
I want to pass a variable from Zend frame work to a native php file in the same server.
what i tried
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$username33 = $this->escape(ucfirst($user->username));
$_SESSION['thisisnotit']=$username33;
}
then i tried this in my php page
echo $notit = $_SESSION['thisisnotit'];
Obviously this gave me an error. I understand the syntax of sessions in Zend is
$myNamespace = new Zend_Session_Namespace('myNamespace');
but how do i get this to work so that i can access the varible in my php file
Answer
Solution:
Your goal is to get auth service. So, for that or for any service you want, first you need to load ZF2 application to get your auth service. Following working/tested code to achieve this -
More efficient way is welcome.