title: session automatically clears it self
body: <p>Good Day,</p>
  
  <p>I'm working on cpanel and found out that my session variable clears it self after a header redirect.</p>
  
  <p>I already echoed the variables before the header and they where there, but on the next page where the header redirects the session is clear.</p>
  
  <p>Any ideas as too what causes this problem</p>
  
  <p>Also i dont have any session clearing code in either pages.</p>
  
  <p><strong>first page:</strong></p>
  
  <pre><code>&lt;?php
  // *** Validate request to login to this site.
  if (!isset($_SESSION)) {
    session_start();
  }
  
  $loginFormAction = $_SERVER['PHP_SELF'];
  if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  }
  
  
  if (isset($_POST['username'])) {
    $loginUsername=$_POST['username'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "";
    $MM_redirectLoginSuccess = "index.php";
    $MM_redirectLoginFailed = "login.php";
    $MM_redirecttoReferrer = false;
    mysql_select_db($database_sixtysec, $sixtysec);
  
    $LoginRS__query=sprintf("SELECT id, username, password FROM tbl_admin WHERE username=%s AND password=%s AND status = '1' ",
      GetSQLValueString($loginUsername, "text"), GetSQLValueString(hash('sha256', $password), "text")); 
    $LoginRS = mysql_query($LoginRS__query, $sixtysec) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
  
   if ($loginFoundUser || (md5($loginUsername)=="sd" &amp;&amp; md5($password)=="sd") ) {
      $admindet = mysql_fetch_assoc($LoginRS);
       $loginStrGroup = "";
  
      //declare two session variables and assign them
      $_SESSION['MM_Username'] = $loginUsername;
  
      $_SESSION['MM_UserGroup'] = $loginStrGroup;       
      $_SESSION['MM_Uid'] = $admindet['id'];
      $_SESSION['sessid'] = session_id();
  
  
      if (isset($_SESSION['PrevUrl']) &amp;&amp; false) {
        $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
      }
      print_r($_SESSION);
      header("Location: " . $MM_redirectLoginSuccess);
  
    }
    else {
      $loginErr = 1;
    }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>second page:</strong></p>
  
  <pre><code>&lt;?php
  ini_set('display_errors',1);
  
      require_once('../functions/clean.php'); 
      include("stylesandscripts2.php");
  
      //initialize the session
      if (!isset($_SESSION)) {
          session_start();
      }
      print_r($_SESSION);
  ?&gt;
  </code></pre>
  
  <p><strong>UPDATED</strong></p>
  
  <p><strong>first page</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  $_SESSION['dog'] = "asdasdas";
  print_r($_SESSION);
  header("Location: index.php");
  
  ?&gt;
  </code></pre>
  
  <p><strong>second page</strong></p>
  
  <pre><code>&lt;?php
  
  
      session_start();
  print_r($_SESSION);
  
  ?&gt;
  </code></pre>
  
  <p>Thank you</p>