PHP Sessions Dies on next page
<p>I have a login page wich sends a variable to another page verifying if login is true (1) or false (0). I can echo $_SESSION['logon'] on page1 but just as I go to page2, my session seems to be dead and gives me * Notice: Undefined index: logon in * I have already fiddled with php.ini but to no avail. Register_globals = off by the way. I'm a rookie so I might have passed something wrong, didn't change the right parameter in php.ini, don't know. </p>

<p>Login Page:  </p>

<pre><code>&lt;!DOCTYPE html&gt;
 &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br"&gt;
 &lt;head&gt;
 &lt;title&gt;Alpha&lt;/title&gt;
 &lt;link rel="stylesheet" href="CSS.css"&gt;  
 &lt;script type="text/javascript" src="js/jquery-1.3.1.min.js"&gt;&lt;/script&gt;
 &lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="js/jquery.history.js"&gt;&lt;/script&gt;  
&lt;/head&gt;
&lt;body&gt;
&lt;form id="logbox" method="post" action="verylog.php"&gt;
User     &lt;input id="user" name="user" type="text" required/&gt;
Password &lt;input id="pass" name="pass" type="PASSWORD" required/&gt;
&lt;input id="send" type="submit"/&gt;
&lt;/form&gt;     
&lt;?php
if(isset($_POST['user'])){
    header("Location: verylog.php");
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>verylog.PHP "page1"</p>

<pre><code> &lt;?php
  session_start();
  $user=$_POST['user'];
  $pass=$_POST['pass'];
  $_SESSION['logon']=0;
  $cost   = ['cost' =&gt; 10,];
  $hasheduser=password_hash($user, PASSWORD_BCRYPT,$cost);
  $hashedpass=password_hash($pass, PASSWORD_BCRYPT,$cost);
  $storeuserhash=file_get_contents('sunburn/userburn.txt');
  $storepasshash=file_get_contents('sunburn/passburn.txt');
  if(password_verify($user, $storeuserhash) &amp;&amp; password_verify($pass, $storepasshash)){
    session_regenerate_id(true);
    $_SESSION['logon']=1;
    header ("Location: ../sunburn/selector.php");   
    die();
    //echo $_SESSION['logon'];
  } else{
   header ("Location: ../burnlogin.php");
   die();
  }
?&gt;
</code></pre>

<p>selector.php "Page2"</p>

<pre><code>&lt;?php
      session_start();
      $logon=$_SESSION['logon'];
    if($logon==0){
        //header("Location: index.php");
        exit();
        echo $_SESSION['logon'];
    }else{

?&gt;
                            &lt;!DOCTYPE html&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br"&gt;
&lt;head&gt;
&lt;link rel="stylesheet" href="localhost/CSS.css"&gt; 
&lt;link rel="stylesheet" href="CSS.css"&gt;  
&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="divreg"&gt;    
        &lt;div&gt;
        &lt;a href="../sunburn/register.php"&gt;
        &lt;button  type="button" &gt;-REGISTRAR-&lt;/button&gt;
        &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
        &lt;a href="../sunburn/deltePAGE.php"&gt;
        &lt;button class="button1"  type="button" value="deltePAGE" &gt;-DELETAR-&lt;/button&gt;
        &lt;/a&gt;
        &lt;/div&gt;          
&lt;/div&gt;          
    &lt;div id="select"&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;?php
    }
    ?&gt;
</code></pre>

<p>And I'm sorry about any typo I may have sent. </p>