title: on clicking back button, user profile page open php?
body: <p>I am implementing logout functionality in php. When I click logout link the session is destroyed(using unset($_SESSION['user']) and session_destroy()). After this, page is redirected to login screen. I tried this before as a standalone application in php and it was working properly. But when i implemented it in my actual code only half part is working, i.e session is destroyed but back button is showing user profile page.</p>
  
  <p>userprofile.php</p>
  
  <pre><code>    &lt;?php
  session_start();
  if(!isset($_SESSION['CurrentUser']) &amp;&amp; $_SESSION['CurrentUser']="")
  {
          header('Location:/login.html');
  }
  else{
  
  if(isset($_POST['submit']))
  {
      include('Config.php');
      $UserId=$PostContent=$Visibilty="";
      $Vi=$_POST['Vi'];
      $Us=$_POST['Us'];
      $Po=$_POST['Po'];
      $CreateDate = date("Y/m/d");
      $insert="insert into Post(Vi,Po,Us,CreateDate) values('".$Vi."','".$Po."','".$Us."','".$CreateDate."')";
      $insertresult=mysql_query("$insert");
   if($insertresult)
   {
      header('Location:/userprofile.php');
   }
   else
   {
      echo "problem inserting data";
   }
  }
  
  if(isset($_SESSION['CurrentUser']))
  {
      $user = $_SESSION["CurrentUser"];
      //echo $user;
  }
  
  include("Config.php");
  $select = "select Post.*, concat(registration.Firstname,' ',registration.Lastname) as Name, about.ProfilePic from post LEFT JOIN about On Post.UserId=About.UserId inner join registration on registration.Id = post.UserId where post.UserId ='".$user."' order by post.PostId desc LIMIT 5";
  $selectResult = mysql_query($select);
  //echo $selectResult;
  include("refrences.php");
  ?&gt;
  &lt;style&gt;
  body
  {
  background-color:lightgrey;
  }
  li.hover a:hover i.hover
  {
      background-color:pink;
  }
  
  &lt;/style&gt;
  &lt;body&gt;
  &lt;?php
  include("Nav.php");
  ?&gt;
  &lt;div class="container" style="background-color:whitesmoke;"&gt;
   &lt;form action="" method="post" class="form-horizontal"&gt;
    &lt;div class="col-md-8 col-md-offset-3"&gt;
    &lt;i class="fa fa-share-square-o" style="color:black"&gt; &amp;nbsp;Status &lt;/i&gt;&amp;nbsp;&amp;nbsp;
  &lt;i class="fa fa-image" style="color:black"&gt;&amp;nbsp;Add Photo&lt;/i&gt;&amp;nbsp;&amp;nbsp;
  &lt;i class="fa fa-file-photo-o" style="color:black"&gt;&amp;nbsp Add Album&lt;/i&gt;
  &lt;/div&gt;
  &lt;input type="hidden" name="UserId" value=&lt;?php echo $user;?&gt;&gt;
  
  &lt;div class="form-group"&gt;
  &lt;div class="col-md-6 col-md-offset-3"&gt;
  &lt;textarea  class="form-control" rows="2" name="PostContent" placeholder="What's on your mind???..."&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;div class="col-md-7 col-md-offset-3"&gt;
  &lt;div class="col-md-5"&gt;
  &lt;i class="fa fa-user-plus" style="color:black"&gt;Tag Friends&lt;/i&gt;&amp;nbsp;
  &lt;i class="fa fa-map-marker" style="color:black"&gt;&amp;nbsp Location&lt;/i&gt;&amp;nbsp;
  &lt;i class="fa fa-smile-o" style="color:black"&gt;&amp;nbsp; Symbols&lt;/i&gt;
   &lt;/div&gt;
  &lt;div class="col-md-2"&gt;
      &lt;label class="control-label" style=""&gt;Share with&lt;/label&gt;&lt;/div&gt;
      &lt;div class="col-md-1"&gt;
        &lt;select class="form-control" id="select" name="Visibilty"&gt;
         &lt;option value="Friends"&gt;Friends&lt;/option&gt;
      &lt;option value="Public"&gt;Public&lt;/option&gt;
      &lt;/select&gt;&lt;/div&gt;
  
      &lt;div class="col-md-2 col-md-offset-1"&gt;
      &lt;input type="submit" value="Post" name="submit" class="btn btn-success"&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;?php
      if(mysql_num_rows($selectResult) &gt; 0)
          {
              while($fetch = mysql_fetch_array($selectResult))
                  {
                  ?&gt;
                  &lt;div class="col-md-8 col-md-offset-2 well" style="background-color:white;"&gt;
                      &lt;div class="col-md-2 thumbnail"&gt;
                      &lt;img src="ProfilePic\&lt;?php echo $fetch['ProfilePic']; ?&gt;" alt="&lt;?php echo $fetch['ProfilePic']; ?&gt;"&gt;
                      &lt;/div&gt;
                          &lt;div class="col-md-3"&gt;
                          &lt;p&gt;&lt;a href="#"&gt;&lt;b style="color:darkred;"&gt;&lt;?php echo $fetch['Name']; ?&gt;&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;
                          &lt;span&gt;&lt;?php echo $fetch['PostContent']; ?&gt;&lt;/span&gt;&lt;/br&gt;
                          &lt;i class="fa fa-thumbs-o-up"&gt;Like,&lt;/i&gt;
                          &lt;i class="fa fa-share"&gt;share&lt;/i&gt;
                          &lt;span&gt;&lt;?php echo $fetch['Visibilty']; ?&gt;&lt;/span&gt;
                          &lt;span&gt;&lt;?php echo $fetch['CreateDate']; ?&gt;&lt;/span&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;?php
                  }
          }
  else
          {
              ?&gt;
              &lt;div class="col-md-8 col-md-offset-2"&gt;
                  &lt;div class="alert alert-warning text-center"&gt;
                      Nothing to share..!!
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;?php
          }   
  ?&gt;
  &lt;div class="col-md-3 col-md-offset-5"&gt;
  &lt;input type="submit" value="See More......" name="submit" class="btn btn-success"&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;?php
          }   
  ?&gt;
  </code></pre>