title: Problem with function session_start() (works slowly)
body: <p>I have a problem wtih <code>session_start()</code> on primary server. When I load page for the first time, it takes less than 1 second to complete request. If I'll wait for approximately 12-15 seconds and then reload page, time of loading will be the same. But when I'm trying to refresh page after, for example, 3 or 5 seconds after initial loading, time of the server's response equals 10 seconds.</p>
  
  <p>I made some tests to define a bottleneck in my script and I found out, that function <code>session_start()</code> executes for 9.8 seconds. I'm using PEAR package HTTP_Session2. <strong>Here is code snippet:</strong></p>
  
  <pre><code>HTTP_Session2::useCookies(SESSION_USE_COOKIE);
  /* Next line was added to make logging of execution time possible. */
  self::writeToFile('HTTP_useCookies(1) -&gt; '.self::getWorkTime()); 
  HTTP_Session2::start("SID");
  self::writeToFile('HTTP_start(2) -&gt; '.self::getWorkTime());
  HTTP_Session2::setExpire(time() + SESSION_EXPIRE);
  self::writeToFile('HTTP_setExpire(3) -&gt; '.self::getWorkTime());
  </code></pre>
  
  <p><strong>Text of the logs:</strong></p>
  
  <pre><code>//First loading (13:34:35)
  HTTP_useCookies(1) -&gt; 0.00038
  HTTP_start(2) -&gt; 0.00077
  HTTP_setExpire(3) -&gt; 0.00090
  
  // Second loading (13:34:39)(4 seconds later)
  HTTP_useCookies(1) -&gt; 0.00029
  HTTP_start(2) -&gt; &lt;&lt;&lt;&lt;&lt;&lt; 10.80752 &gt;&gt;&gt;&gt;&gt;
  HTTP_setExpire(3) -&gt; &lt;&lt;&lt;&lt;&lt;&lt; 10.80780 &gt;&gt;&gt;&gt;&gt;
  
  //Third loading (13:34:56)
  HTTP_useCookies(1) -&gt; 0.00041
  HTTP_start(2) -&gt; 0.00071
  HTTP_setExpire(3) -&gt; 0.00083
  </code></pre>
  
  <p>So I found, that problem is in the <code>HTTP_Session2::start()</code> function. Code of the function <code>HTTP_Session2::start()</code>: </p>
  
  <pre><code>public function start($name = 'SessionID', $id = null)
  {
    self::name($name);
    if (is_null(self::detectID())) {
      if ($id) {
        self::id($id);
      } else {
        self::id(uniqid(dechex(rand())));
      }
    }
    session_start();
    if (!isset($_SESSION['__HTTP_Session2_Info'])) {
      $_SESSION['__HTTP_Session2_Info'] = self::STARTED;
    } else {
      $_SESSION['__HTTP_Session2_Info'] = self::CONTINUED;
    }
  }
  </code></pre>
  
  <p>I can't understand what is the cause of time delay. Probably, there are wrong Apache settings on the server. Or, maybe, there are some 'locks' on files with session information. </p>
  
  <p>Maybe, someone has already encountered such problems and can help to solve it.</p>