title: Session is restarting on a specific page
body: <p>I am developing a php based site for a uni project.</p>
  
  <p>Everything is working and I am using a session to store data on users who are logged in.</p>
  
  <p>I have a page where, using jquery, the user can tag an image. The jquery uses php to save a txt file with the tags in it. In that php page i added "session_start();" at the top so that I could also store some info in the mysql db.</p>
  
  <p>But I have discovered that when I tag an image, what is actually happening is that the session is being restarted, so the user is being logged out, and nothing is being stored in the db.</p>
  
  <p>Any ideas what I could be doing wrong? (It's working on all other pages of my project, only this javascript+php combo seems to be causing a problem).</p>
  
  <p>Here is the code from the php page which gets called by the javascript. It's from a third party jquery plugin and I have added my own code to it:</p>
  
  <pre><code>session_start();
  
      include 'notes.class.php';
      require_once '../db.php';
  
      if (isset($_POST['image']) &amp;&amp; !empty($_POST['image']))
      $oNote = new note('../jquery-notes_notes/', '', (string) strip_tags($_POST['image']), '.note');
          $NoteName = md5(strip_tags($_POST['image']));
          $NoteName .= '.note';
          $ImageID = $_SESSION['CurrentImage'];
  
          //get the name of the last poster if the user is logged in, its the username, otherwise its the comment name
          if ($_SESSION['logged_in'] == 1) {
              $LastNoteBy = $_SESSION['username'];
          } else {
              $LastNoteBy = 'Guest: '.$_SESSION['commentname'];
          }
  
          //get relevant info for this image
          $DBQueryImageData = mysqli_query($dblink, "SELECT * FROM images WHERE image_id = '$ImageID'");
          while($row = mysqli_fetch_array($DBQueryImageData)) {
              $DBImageUserID = $row['user_id'];
              $DBImageName = $row['image_name'];
              $DBGivenName = $row['given_name'];
              $DBImageLasteNoteBy = $row['last_note_by'];
              $DBImageProjectID = $row['project_id'];
          }
  
          //get the project name of the related project
          $DBQueryProjectName = mysqli_query($dblink, "SELECT * FROM projects WHERE project_id = '$DBImageProjectID'");
          while($row = mysqli_fetch_array($DBQueryProjectName)) {
              $DBProjectName = $row['project_name'];
          }
  
          //get the username of the owner of the previously obtained user_id
          $DBQueryUsername = mysqli_query($dblink, "SELECT * FROM users WHERE user_id = '$DBImageUserID'");
          while($row = mysqli_fetch_array($DBQueryUsername)) {
              $DBUsername = $row['username'];
              $DBEmail = $row['email'];
              $DBNotify = $row['notify'];
          }
  
          //only send off the email if the user has asked to receive notifications
          if ($DBNotify == 1) {
  
              //compare the current poster to the last poster saved for this image, if they are different, and if the current poster is not the owner, email the owner of the project
              //if the last poster is not the same as the current poster
              if ($DBImageLasteNoteBy != $LastNoteBy) {
  
                  //if the current poster is not the owner
                  if ($LastNoteBy != $DBUsername) {
  
                      if (strlen($DBGivenName) &gt; 4) {
                          $DBImageName = $DBGivenName;
                      }
  
                      //send the email
                      $to = $DBEmail;
                      $subject = "New comment on your project image";
                      $headers = 'From: test@test.com' . "\r\n" .
                      'Reply-To: test@test.com' . "\r\n" .
                      'X-Mailer: PHP/' . phpversion();
                      $additionalParameters = '-ODeliveryMode=d'; 
                      $body = 'Hi '.$DBUsername.','."\n\n".'A comment has been made by '.$LastNoteBy.' on your image: '.$DBImageName.' in your project: '.$DBProjectName."\n\n".
                      'http://'.$_SERVER['SERVER_NAME'].'/saeproj/index.php?page=project&amp;id='.$DBImageProjectID;
  
                      mail($to, $subject, $body, $headers, $additionalParameters);
  
                  }
              }
          }
  
          mysqli_query($dblink, "UPDATE images SET note = '$NoteName', last_note_by = '$LastNoteBy' WHERE image_id = '$ImageID'") or die(mysql_error());
  </code></pre>
  
  <p><strong>Update:</strong> I just noticed that I am not being logged out on my MAMP version that's running on my iMac. But I am being logged out on my hosted webspace (ipower is the host).</p>
  
  <p><strong>Update 2:</strong> i just checked and the session id is not changing but session['logged-in'] is being changed to 0. If the session id is not changing then the session has not restarted, correct?</p>