title: Zend_Session and Zend_Log _Db are both writing to the database twice for every page load
body: <p>There are plenty of examples of similar problems littered around the web but none of their solutions seem to fix this particular variation. Any suggestions would be appreciated. </p>
  
  <p>Usually this problem occurs because a rogue link is causing a request for a resources like a favicon or css file to hit the dispatcher more than once, thus causing multiple dispatch processes and therefore multiple rows in your database.</p>
  
  <p>I have checked that all the links on this very simple example page do actually resolve to the resource to which they point.</p>
  
  <p>The session handler is setup as follows:</p>
  
  <pre><code>Zend_Db_Table_Abstract::setDefaultAdapter($db);
  Zend_Session::setSaveHandler(new 
              Zend_Session_SaveHandler_DbTable($config-&gt;session-&gt;toArray()));
  </code></pre>
  
  <p>The db logging is setup as follows:</p>
  
  <pre><code>$writer = new Zend_Log_Writer_Db($db, $config-&gt;log-&gt;tableName, 
              $config-&gt;log-&gt;columnMap-&gt;toArray());
  $logger = new Zend_Log($writer);
  </code></pre>
  
  <p>Both objects are correctly setup and can read and write to and from the database. Only everything happens twice. If I put a test log message anywhere in the application it is written into the database twice. If I increment three variables with every call to the index action - one stored in the session, one passed around via a Zend_Registry object and another local to the indexAction - only the session variable is incremented by 2. The Apache access log shows the correct amount of requests being fired from the page load and all have good response codes of either 200 or 304 (unchanged).</p>
  
  <p>I have tried disabling all head links.
  I have tried disabling the layout entirely.
  I have localised everything to the dispatcher and exited before dispatch is run.</p>
  
  <p>In all cases the extra write/increment takes place.
  Any thoughts?
  Thanks in advance for any help.</p>