title: session_start() not working properly
body: <p>I hope you are doing great,
  I'm making this website with login accounts apparently, I have registered my users in a local database and in a server database. My HTML/PHP code doesn't show any errors when I run it.I have checked my DB connection. it's correct. The website allows me to sign in with any user and password. It doesn't seem to validate my entered data properly. Although I checked my SQL command.
  I wonder if you could help me with this guys. You are the best! :)
  thanks in advance, Cheers
  here is a useful piece of my code:
  My header - Header.php:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;?php
  /* static $called = FALSE;
  if (!$called)
  {*/
  session_start();
  /*$called = true;
  }*/
  
  include_once 'debugging.php';
  ?&gt;
  &lt;head&gt;
      &lt;link href="style.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div &gt;
          &lt;dt id="navbar1" class ="navbar"&gt;
          &lt;a href="Index.php" class="followingLink"&gt;Home&lt;/a&gt;
          &lt;a href="Upload.php"&gt;Upload Videos&lt;/a&gt;
          &lt;/dt&gt;
      &lt;/div&gt;
      &lt;?php
      if (isset($_SESSION['logged'])) { 
      echo '&lt;div class="right navbar" id = "navbar2"&gt;
      &lt;a href="Index.php" class = "right followingLink1"&gt;Log out&lt;/a&gt;                
      &lt;p class = "right"&gt;/&lt;/p&gt;
          &lt;a href="Edit_Account.php" class = "right"&gt;Edit Account&lt;/a&gt;
      &lt;img src="http://www.extremetech.com/wp-content/uploads/2013/11/emp-blast.jpg?type=square"
      height="42" width="42" class = "right"/&gt;
      &lt;/div&gt;';
       } else {
        echo '&lt;div class="right navbar" id = "navbar2"&gt;
        &lt;a href="Login.php" class = "right"&gt;Login&lt;/a&gt;
        &lt;p class = "right"&gt;/&lt;/p&gt;
        &lt;a href="Sign_Up.php" class = "right"&gt;Sign Up&lt;/a&gt;
        &lt;/div&gt;';
        } 
      ?&gt;
  </code></pre>
  
  <p>Progress - Feedback:</p>
  
  <p>Ok guys, I tried what you told me to do. It started to make me sign in automatically. Probably the session['logged'] variable declaration is considered to be true. I set it to be true only if the user login from the login page. but it is not functioning in that way.
  Here is my login page code:</p>
  
  <pre><code>&lt;?php
      include_once 'Header.php';
      ?&gt;
  
          &lt;div id="container"&gt;
              &lt;br&gt;
  
  
              &lt;?php
              /*
                if($_DEBUG)
                {
                ini_set('display_errors', 1);
                ini_set('log_errors', 1);
                ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
                error_reporting(E_ALL);
                }
  
  
                $page_title = 'Login';/* */
  
      //in this page we do things slightly differently - the code for validation    
      and displaying messages is done
      //before we display the form 
              echo '&lt;div id = "div_1"&gt;&lt;h1&gt;Login&lt;/h1&gt;';
  
      //display the form
              echo '&lt;div id="div_2"&gt;&lt;div id="div_2"&gt;
         &lt;form action="index.php" method="post"&gt;
             &lt;label&gt;UserName&lt;br&gt;
             &lt;span class="small"&gt;enter your username&lt;/span&gt;
             &lt;/label&gt;
             &lt;input type="text" name="UserName" value=""/&gt;
  
             &lt;label&gt;&lt;br&gt;Password&lt;br&gt;
             &lt;span class="small"&gt;enter your password&lt;/span&gt;
             &lt;/label&gt;
             &lt;input type="password" name="Password" /&gt;
  
             &lt;button type="submit" name="submit" value="Login" /&gt;Log in&lt;/button&gt;
             &lt;input type ="hidden" name="submitted" value="TRUE"&gt;
           &lt;/form&gt;
           &lt;/div&gt;
      &lt;/div&gt;';
  
               if (isset($_POST['submitted'])) {
                //require_once is similar to 'include' but ensures the code is not 
      copied multiple times  
                require_once('LoginFunctions.php');
  
                //list() is a way of assigning multiple values at the same time
                //checkLogin() function returns an array so list here assigns the 
      values in the array to $check and $data
                list($check, $data) = checkLogin($_POST['UserName'], 
      $_POST['Password']);
  
                if ($check) {
                setcookie('FName', $data['FName'], time()+ 900 ) ;  //cookie  
      expires after 15 mins
                setcookie('LName', $data['LName'], time() + 900 ) ;
                //
                //use session variables instead of cookies
                //these variables should now be available to all pages in the 
      application as long as the users session exists
                $_SESSION['FName'] = $data['FName'];
                $_SESSION['LName'] = $data['LName'];
                $_SESSION['UserName'] = $data['UserName'];
                //to enable $_SESSION array to be populated we always need to call 
      start_session() - this is done in header.php
                //print_r is will print out the contents of an array
                print_r($_SESSION);
                //
                //Redirect to another page
                $url = absolute_url('Index.php');  //function defined in 
      Loginfunctions.php to give absolute path for required page
                $_SESSION['logged'] = TRUE;
                //this version of the header function is used to redirect to 
      another page
                header("Location: $url");//since we have entered correct login 
      details we are now being directed to the home page
  
                exit();
                } else {
                $errors = $data;
                }
                }
  
                //create a sopace between the button and the error messages
                //echo'&lt;div class="spacer"&gt;&lt;/div&gt;';
  
                if (!empty($errors)) {
                echo '&lt;br/&gt; &lt;p class="error"&gt;The following errors occurred: &lt;br  
      /&gt;';
  
                //foreach is a simplified version of the 'for' loop
                foreach ($errors as $err) {
                echo "$err &lt;br /&gt;";
                }
  
                echo '&lt;/p&gt;';
                }
  
                //this is the end of the &lt;div&gt; that contains the form
                echo '&lt;/div&gt;';
  
                /* */
              ?&gt;
          &lt;/div&gt;
  
      &lt;?php
      include 'Footer.php';
      ?&gt;
  </code></pre>