title: Testing Magento with PHPUnit: Problems with Memcache sessions
body: <p>We are using the EcomDev package to test our Magento store, and one of the default tests is kicking up a fuss:</p>
  
  <p>Running phpunit returns:</p>
  
  <pre><code>5) EcomDev_PHPUnitTest_Test_Helper_Customer::testCustomerSession with data set "jane_doe" (2)
  Exception: Warning: session_module_name(): A session is active. You cannot change the session module's ini settings at this time  in /var/www/htdocs/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 73
  
  Fatal error: Uncaught exception 'Exception' with message 'Warning: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://tcp://127.0.0.1:11211?persistent=1&amp;weight=2&amp;timeout=10&amp;retry_interval=10)
  </code></pre>
  
  <p>So far I established that:</p>
  
  <ul>
  <li>Memcache seems to be on, and on the correct port</li>
  <li>The same problem occurs when I set it up to use external (AWS) Memcache service</li>
  <li>Same thing happens if I set the session to be handled by filesystem</li>
  </ul>
  
  <p>The config for magento's session is:</p>
  
  <pre><code>&lt;session_save&gt;&lt;![CDATA[memcache]]&gt;&lt;/session_save&gt;
  &lt;session_save_path&gt;&lt;![CDATA[tcp://127.0.0.1:11211?persistent=1&amp;weight;=2&amp;timeout;=10&amp;retry;_interval=10]]&gt;&lt;/session_save_path&gt;
  &lt;session_cache_limiter&gt;&lt;![CDATA[private]]&gt;&lt;/session_cache_limiter&gt;
  &lt;lifetime&gt;31536000&lt;/lifetime&gt;
  </code></pre>
  
  <p>And php5-fpm php.ini has </p>
  
  <pre><code>session.save_handler = memcache
  session.save_path = "tcp://127.0.0.1:11211?persistent=1&amp;weight;=2&amp;timeout;=10&amp;retry;_interval=10"
  </code></pre>