title: PHP not saving sessions on subdomain, ok on domain
body: <p>We have a CentOS 5.4 server serving a number of our websites. The server is managed by Plesk 9.2.3.
  Our websites are developed in php.</p>
  
  <p>We have our main domain ourapplication.co.uk in /var/www/vhosts/ourapplication.co.uk/httpdocs, and
  our subdomain api.ourapplication.co.uk in /var/www/vhosts/ourapplication/subdomains/api/httpdocs</p>
  
  <p>The following pages are in BOTH locations:</p>
  
  <p><strong>davidstest1.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=7" /&gt;
  &lt;title&gt;Code Blue Stats&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/style.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  echo "This is Davids Test 1. It will set SESSION['davids']='davids variable set' and then link
  to davidstest2.php&lt;br /&gt;
  davidstest2 wil then do a session_start() call, and attempt to display SESSION['davids'] &lt;br /&gt;";
  $_SESSION['davids']='davids variable set';
  ?&gt;
  &lt;a href="davidstest2.php"&gt;davidstest2.php&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>davidstest2.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=7" /&gt;
  &lt;title&gt;Code Blue Stats&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/style.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  echo "This is Davids Test 2. It will do a session_start() call, and attempt to display SESSION['davids'] &lt;br /&gt;";
  $r=print_r($_SESSION, true);
  echo "&lt;pre&gt;Session in &lt;br /&gt;";
  echo $r;
  echo "&lt;br /&gt;&lt;/pre&gt;";
  ?&gt;
  &lt;a href="davidstest2.php"&gt;davidstest2.php&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>in the MAIN domain, davidstest2 returns</p>
  
  <pre><code>This is Davids Test 2. It will do a session_start() call, and attempt to display SESSION['davids'] 
  Session in 
  Array
  (
      [siteMode] =&gt; none
      [davids] =&gt; davids variable set
  ) 
  davidstest2.php
  </code></pre>
  
  <p>in the api SUBDOMAIN, davidstest2 returns</p>
  
  <pre><code>This is Davids Test 2. It will do a session_start() call, and attempt to display SESSION['davids'] 
  Session in 
  Array
  (
  )
  davidstest2.php
  </code></pre>
  
  <p>Obviously, something in the Apache config or the Php config is wrong, as the session variable should be stored for both domains</p>
  
  <pre><code>Relevant phpinfo() reports:
  Session Support enabled
  Registered save handlers    files user
  Registered serializer handlers  php php_binary wddx
  session.auto_start  Off Off
  session.bug_compat_42   Off Off
  session.bug_compat_warn On  On
  session.cache_expire    180 180
  session.cache_limiter   nocache nocache
  session.cookie_domain   no value    no value
  session.cookie_lifetime 0   0
  session.cookie_path /   /
  session.cookie_secure   Off Off
  session.entropy_file    no value    no value
  session.entropy_length  0   0
  session.gc_divisor  1000    1000
  session.gc_maxlifetime  1440    1440
  session.gc_probability  1   1
  session.hash_bits_per_character 5   5
  session.hash_function   0   0
  session.name    PHPSESSID   PHPSESSID
  session.referer_check   no value    no value
  session.save_handler    files   files
  session.save_path   /var/lib/php/session    /var/lib/php/session
  session.serialize_handler   php php
  session.use_cookies On  On
  session.use_only_cookies    Off Off
  session.use_trans_sid   0   0
  </code></pre>
  
  <p>Any ideas where to start looking?</p>