title: Checking for PHP session without starting one?
body: <p>Is it possible to check for a session with out starting one?</p>
  <p>The reason that I ask is, the app I am developing has an integrated admin interface. So when an admin is logged in they browse the same pages as the users to make their edits. Fields and options are shown based on the users privs.</p>
  <p>This is causing two problems.</p>
  <p><strong>One</strong> is Because a session is being started, I can not enable browser caching features as the headers being sent are always:</p>
  <pre><code>Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0       
  </code></pre>
  <p>I am using smarty to output the templates, and can't implement the:</p>
  <pre><code>$smarty-&gt;cache_modified_check = true;
  </code></pre>
  <p>to send a 304 not modified because a session has already been started. Using the above smarty param would be the perfect solution to browser caching for me.</p>
  <p><strong>Two</strong> is because every person using the site is starting a session the session directory gets filled with unneeded sessions.</p>
  <p>I could just destroy the session if the user is not logged in, but then every single page load, the user would be creating and deleting a session. Is that bad practice?</p>
  <p>So if I could just check to see if an active session exists without starting one all my problems would be solved. Any ideas? Doesn't the browser send the session cookie when requesting the page?</p>
  <h2>Something Ideally like this:</h2>
  <pre><code>if (session_exists) {
   session_start();
   $users-&gt;priv = $_SESSION['priv'];
  }
  else {
   $users-&gt;priv = guest;
  }
  </code></pre>
  <p><strong>--------------- In response to Tony Miller ---------------</strong></p>
  <p>When using session_id(), you have to already have a session started for it to return an id.</p>
  <pre><code>session_start();
  echo session_id($_SESSION);
  </code></pre>
  <p>or you can set an id for the session before calling session start</p>
  <pre><code>session_id(&quot;adfasdf&quot;);
  session_start();
  echo session_id($_SESSION);
  
  //prints &quot;adfasdf&quot;
  </code></pre>
  <p><strong>Neither of these help me. Unless I am missing something.</strong></p>