views:

62

answers:

1

Hi there,

I am using Zend Framework and 3rd party application written in php for file upload. Upload process is ajax like, and I have annoying problem probably caused by this app.

Problem is that upload application somehow destroys my Zend_Session!

Here is the error which I am getting (with firebug console):

http://pastie.org/738834

And this is code in my ZF controller which works fine, but after the error displayed abbove, If I go to this controller I will be redirected to google.com

public function init()
    {
        $this->_projects = new Projects();
        $this->_memberSes = new Zend_Session_Namespace('MyMember');
    }

    public function preDispatch()
    {
        $member = $this->_memberSes->member;

        if ($member==null){
            $this->_redirect('http://www.google.com');
        }
    }

Problematic code in 3rd party app looks like this: http://pastie.org/738837

I know that my question isn't perfectly clear, but I am out of ideas and any kind of help means to me a lot! Thanks.

A: 

This is what's happening:

  1. A object instance of class ObjectClass is being serialized to the session.
  2. On request shutdown, the session text is stored.
  3. On the next request, the session text is retrieved and unserialized.
  4. But, when PHP tries to unserialize your object, it doesn't know about ObjectClass, because the ObjectClass class file wasn't included this request, just last request when it was created. It lost the blueprint, so to speak.

So, figure out which class is being stuffed into the session, and ensure that you include it every request, just in case.

Edit: Or, as Nicky said, autoloader may help here:

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('MyApp_');
$autoloader->setFallbackAutoloader(true);
Derek Illchuk
or make sure the autoloader can always find it
Nicky De Maeyer
Tnx for answers people, so u think that problem is in my ZF code ?It is probably because without doctrine I don't have this problem.I have a bootstrap and as far as I know autoloading of doctrine models is enabled, please take a look at my Bootstrap.phphttp://pastie.org/738956
Splendid
When you enable AutoLoader, as I've shown above, it will report exactly which class couldn't be found. So, for example, if the TestObject class is the offender, it will report that TestObject.php could not be loaded.
Derek Illchuk
Will accept the answer but your solution didn't solved the problem in my case, I avoided object storing in session, and problem is solved
Splendid