title: Zend_Session : Clean $_SESSION before calling start
body: <p>Let's say a web application store an object of class My_Object in the php session, under the name 'myobject'. When I open another php application where this class doesn't exist, Zend_Session::start() throw an exception when attempting to unserialize My_Object.</p>
  
  <p>Thus, I need to clean the $_SESSION variable to get rid of 'myobject'. But to clean $_SESSION variable, I first need to call session_start() and once it has been called, Zend_Session::start() throws the following exception :</p>
  
  <blockquote>
    <p>Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()'</p>
  </blockquote>
  
  <p>This is thrown even if I class session_destroy() before calling Zend_Session::start().</p>
  
  <p>Can anyone help me on this ?</p>
  
  <p>Thanks by advance,</p>
  
  <p>Eric.</p>
  
  <p>EDIT : To add clarification, here is the function I call on my controller initializer plugin :</p>
  
  <pre><code>    protected function _initSession() {
          try {
              session_start();
  
              unset($_SESSION['myobject']);
  
              session_destroy();
  
              Zend_Session::start(); // throws an exception !!!
          }
          catch (Exception $e) {
              echo $e; exit;
          }
      }
  </code></pre>
  
  <p>EDIT 2 :</p>
  
  <p>To add further clarification, here is the exception thrown by Zend_Session::start() when it encounters an unknown class :</p>
  
  <blockquote>
    <p>Warning: include_once(My/Object.php): failed to open stream: No such file or directory in /usr/local/zend/share/ZendFramework/library/Zend/Loader.php on line 146</p>
  </blockquote>
  
  <p>Now that I've written this, I wonder if I sould start the session before instanciating the Zend autoloader...</p>