How can I use Zend_Auth with Zend_Json_Server?

442 views Asked by At

Zend's JSON-RPC server doesn't seem to like sessions, and I can't seem to attach a session even by passing Zend_Session::getId() in to my RPC method and revive it with Zend_Session::setId($session_id) as I might expect.

To illustrate what does NOT work:

<?php

$server = new Zend_Json_Server();
$server->setClass('MyRPC');
?>
<script>
$(document).ready(function() {
    myrpc = jQuery.Zend.jsonrpc({
        url : <?=json_encode($this->baseUrl('/ajax'))?>
        , smd : <?=$server->getServiceMap()?>
        , async : true
    });
    myrpc.getIdentity(<?=json_encode(Zend_Session::getId())?>, {
        success : function(data) {
            alert(data.user_id);
        }
    });
});
// see: http://www.tanabi.com/projects/jsonrpc

</script>

and in my RPC class:

<?php

class MyRPC {

    /**
     * @param string
     * @return array
     */
    public function getIdentity($session_id) {
        \Zend_Session::setId($session_id);
        \Zend_Session::start();
        // returns NULL
        return \Zend_Auth::getInstance()->getIdentity();
    }

}
1

There are 1 answers

0
Stephen Fuhry On BEST ANSWER

It looks like this is unimplemented.