title: Session not recognized
body: <p>I spent about 45 minutes yesterday trying to research and troubleshoot this, so hopefully someone has another idea I can try.</p>
  
  <p>It started out with one of my PHP scripts detecting that the session <code>$_SESSION</code> was empty, so it stopped executing the rest and threw an error for me.</p>
  
  <p>This entire project has worked on that server for at least half a year without any problems, and no update to code or server has been made since then.</p>
  
  <p>Here's what I did then:
  I created a new PHP file for testing, made sure there was nothing before or after the <code>&lt;?php ?&gt;</code> container, and wrote this code:</p>
  
  <pre><code>session_start();
  var_dump($_SESSION);
  $_SESSION['test'] = 5;
  </code></pre>
  
  <p>Then I ran the file by itself repeatedly, and it always came up with an empty session.</p>
  
  <p>I had run into this before, so I checked the folder where the session files are located on the server (in my case <code>/var/lib/php5</code>), made sure it had the correct directory owner and permissions, deleted all the files in it and restarted apache.
  No dice...</p>
  
  <p>I ran the file again a few times, and each run created a NEW session file, and the session file did contain the test=5 entry, so sessions do write correctly.</p>
  
  <p>So I checked the browser cookies. They are there and working as far as I can tell - both the phpsessid cookie and another cookie my site creates were there. If I delete all cookies and then run my test file again, the <code>phpsessid</code> cookie is recreated normally and does contain the same session id that was created as a session file.</p>
  
  <p>I also added <code>var_dump(session_id());</code> to the code right after <code>session_start();</code>, and it gave me a brand new session id every time the script ran.</p>
  
  <p>We're running a PHP version that does not support <code>session_status()</code> yet, so that's not an option, either (not sure exactly what it would do, anyway, I'm flying rather blindly here).</p>
  
  <p>So, we know sessions are created properly, the files contain the data, the cookie contains the correct id.</p>
  
  <p>So as far as I can tell, the issue must lie either with the browser not sending the cookie data back to the server or the server not recognizing the session id from the cookie as an existing session.</p>
  
  <p>While I was testing this, Firefox wanted to install an update, so I ran the update, but no change.
  Firefox is set to receive cookies, and I did not find any exception set anywhere that would prevent them.</p>
  
  <p>Given that this has been working fine for over 6 months, some freak accident must have corrupted something, but I don't know enough about Linux or the internal workings of PHP and sessions to even know where the start diagnosing.</p>
  
  <p>At some point I did try <code>session_write_close()</code> which didn't change anything (and my whole project has always been working fine without it).</p>
  
  <p>The ONLY thing that worked was this:</p>
  
  <pre><code> $c = $_COOKIE['phpsessid'];
   session_name($c);
   session_start();
   var_dump($_SESSION);
   $_SESSION['test'] = 5;
  </code></pre>
  
  <p>But I use <code>session_start</code> in a ton of pages and don't want to go through all of them to enter code that I shouldn't need in the first place...</p>
  
  <p>Any thoughts?</p>
  
  <p>Thanks in advance!</p>
  
  <p>--- EDIT ---</p>
  
  <p>I checked into the issue again, and I can confirm that the cookie name is <code>phpsessid</code> instead of <code>PHPSESSID</code> (thanks for pointing that out, @Cobra_Fast), so that is getting closer to the cause of the issue. I went into the <code>php.ini</code> file to put the value for <code>session.name</code> into quotation marks, then restarted apache, but still no change - the cookie name is still lower case. I haven't found an antivirus program on the computer, and I doubt that there's any network security that could do this... If the PHP settings are corrupted as @Cobra_Fast suggested, how could this be fixed? Editing the file just now didn't help...</p>