Search code examples
zend-frameworkzend-session

Zend_Session_Namespace from non-Zend PHP


I need to integrate my no-framework code with my brand new Zend Application. But they need to share a session. The problem I am facing is - when I am setting the session variables from the non-zend php using

$_SESSION['MyApp']['user']=$user;

I cant access the session from the Zend Application, i tried both -

print_r($_SESSION['MyApp']['user']);

and

$myAppSession = new Zend_Session_Namespace('MyApp');
print_r($myAppSession->user);

Doesn't work. Info - I have

resources.session.name = "MyApp"

in my bootstrap ini file.


Solution

  • I found a way out, Zend Session has a different session id than normal PHP sessions, so what I did was to send the session id from zend with the request and start the session with that session id -

        if(isset($_REQUEST['sess_id'])) {
            $sess_id = $_REQUEST['sess_id'];
        }
    
        session_id($sess_id);
        session_start();
    

    Its not beautiful code, but it works.