title: Session variable not passed in live server
body: <p>I have tried out some code in php for user registration this whole code works fine on local server but when it comes to live server every php code is getting executed but session variables are not displayed but in local server session variables are passed and displayed properly</p>
  
  <p><strong>DB_Function.php</strong></p>
  
  <pre><code>public function storeUser($salutation, $fname, $lname, $dob, $mobile, $country, $state, $city, $pin){  
      try {
          //$hash = md5($password);
          $characters = '0123456789';
              $uuid = '';
              $random_string_length = 5;
          for ($i = 0; $i &lt; $random_string_length; $i++) {
              $uuid .= $characters[rand(0, strlen($characters) - 1)];
          }
          $fullname = $fname . " " . $lname;
          $vault_no = $salutation . "" . $country . "" . $pin . "" . $uuid;
          $sql = "INSERT INTO users(salutation, fname, lname, fullname, dob, mobile, country, state, city, pin, unique_id, vault_no, created_at) VALUES ('$salutation', '$fname', '$lname', '$fullname', '$dob', '$mobile', '$country', '$state', '$city', '$pin', '$uuid', '$vault_no', NOW())";
          $dbh = $this-&gt;db-&gt;prepare($sql);
  
          /*execute the insert query in 
          get the user details return
          */
          if($dbh-&gt;execute()){
              // get user details
              $sql = "SELECT * FROM users WHERE mobile = '$mobile' LIMIT 1";
              $dbh = $this-&gt;db-&gt;prepare($sql);
              $result = $dbh-&gt;execute();
              $rows = $dbh-&gt;fetch();
              $n = count($rows);
              if($n){
                  return $rows;
              }
          }
      }
      catch (Exception $e) {
          die('Error accessing database: ' . $e-&gt;getMessage());
      }
      return false;
  }
  </code></pre>
  
  <p><strong>fill.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
   ?&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  
      &lt;title&gt;MiiSKy | Register&lt;/title&gt;
      &lt;script type="text/javascript" src="jquery_source.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src = "register.js"&gt;&lt;/script&gt;
      &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link href="font-awesome/css/font-awesome.css" rel="stylesheet"&gt;
      &lt;!--&lt;link href="css/plugins/iCheck/custom.css" rel="stylesheet"&gt;--&gt;
      &lt;link href="css/animate.css" rel="stylesheet"&gt;
      &lt;link href="css/style.css" rel="stylesheet"&gt;
      &lt;!--&lt;script src='https://www.google.com/recaptcha/api.js'&gt;&lt;/script&gt;--&gt;
  
      &lt;link href="css/plugins/iCheck/custom.css" rel="stylesheet"&gt;
  
      &lt;link href="css/plugins/datapicker/datepicker3.css" rel="stylesheet"&gt;
      &lt;!--Dropzone--&gt;
      &lt;link href="css/plugins/dropzone/basic.css" rel="stylesheet"&gt;
      &lt;link href="css/plugins/dropzone/dropzone.css" rel="stylesheet"&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  
  
  
  &lt;/head&gt;
  
  &lt;body class="gray-bg"&gt;
  
      &lt;div class="middle-box text-center loginscreen   animated fadeInDown"&gt;
          &lt;div&gt;
              &lt;div&gt;
  
                  &lt;!--&lt;h3 class="logo-name"&gt;MiiSky&lt;/h3&gt;--&gt;
                  &lt;img src="img/landing/mii-logo.png"&gt;
              &lt;/div&gt;
              &lt;!--&lt;h3&gt;Register to MiiSky&lt;/h3&gt;--&gt;
              &lt;p&gt;Create your vault to see it in action.&lt;/p&gt;
              &lt;form id = "form" name = "form" class="validate-form" method="POST" action="formprofile.php" autocomplete = "off" &gt;
  </code></pre>
  
  <p><strong>register.js</strong></p>
  
  <pre><code>/* (.ready)Executes the 
      function on 
      complete load
  */
  $(document).ready(function(){
  
      /*executes the function 
      on click of id 'submit'
      */
      $("#submit").click(function(e){
  
      //validate front-end prior to back-end
          var status = $('form')[0].checkValidity();
          if(status){
              /*jquery to call the url requested 
              and parse the data in json*/
              $.ajax({
                  url: "register.php",
                  type: "POST",
                  //form serialization of the all parameters
                  data: $("#form").serialize(),
                  async: false,
                  //data passed in json
                  dataType: "JSON",
                  /*Give out the alert box
                  to display the results*/                
                  success: function (json){
                      /*if error exists alert
                      the user*/
                      if(json.error){
                          alert(json.error_msg);
                          e.preventDefault();
                      }else{
                          //on successs of process
                          alert("Registeration successful!");
                          $('#form').submit();
                      }
                  },
                  //through out error from back-end if exist
                  error: function(jqXHR, textStatus, errorThrown){
                      alert(errorThrown);
                  }
              });
          }
  
      });
  
  }); 
  </code></pre>
  
  <p><strong>register.php</strong></p>
  
  <pre><code> &lt;?php
          session_start();
          require_once 'DB_Functions.php';
          $db = new DB_Functions();
  
          // json response array
          $response = array("error" =&gt; false);
          if (!empty($_POST['salutation']) &amp;&amp; !empty($_POST['fname']) &amp;&amp; !empty($_POST['lname']) &amp;&amp; !empty($_POST['dob']) &amp;&amp; !empty($_POST['mobile']) &amp;&amp; !empty($_POST['country']) &amp;&amp; !empty($_POST['state']) &amp;&amp; !empty($_POST['city']) &amp;&amp; !empty($_POST['pin'])){
                  /*
                  if required include seperate validation
                  for some fields which require validation
                  */
                  // receiving the post params
                  $salutation = ($_POST['salutation']);
                  $fname = trim($_POST['fname']);
                  $lname = trim($_POST['lname']);
                  $dob = trim($_POST['dob']);
                 /* $email = trim($_POST['email']);
                  $password = $_POST['password'];*/
                  $mobile = trim($_POST['mobile']);
                  $country = trim($_POST['country']);
                  $state = trim($_POST['state']);
                  $city = trim($_POST['city']);
                  $pin = trim($_POST['pin']);
  
                  /*
                  validation process
                  starts from here
                  */
  
                  // validate your email address
  
                 /* if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
                          //validate your password
                          if(strlen($password) &gt;= 6){*/
                                  //validate your mobile
                                  //$mobile="/^[1-9]*$/";
                                  if(strlen($mobile) == 10){
                                           //Check for valid email address
                                           /*if ($db-&gt;isUserExisted($email)) {
                                                                  // user already existed
                                                                  $response["error"] = true;
                                                                  $response["error_msg"] = "User already existed with " . $email;
                                                                  echo json_encode($response);
                                                          }*/
                                                          if($db-&gt;isMobileNumberExisted($mobile)) {
                                                                          //user already existed
                                                                          $response["error"] = true;
                                                                          $response["error_msg"] = "user already existed with" . $mobile;
                                                                          echo json_encode($response);
                                                          }else{  
                                                                  // create a new user
                                                                  $user = $db-&gt;storeUser($salutation, $fname, $lname, $dob, $mobile, $country, $state, $city, $pin);
                                                                  if ($user) {
                                                                          // user stored successfully
                                                                          $response["error"] = false;
                                                                          $_SESSION["fullname"] = $user["fullname"];
                                                                          $_SESSION["vault_no"] = $user["vault_no"];
                                                                          echo json_encode($response);
                                                                  } else {
                                                                          // user failed to store
                                                                          $response["error"] = true;
                                                                          $response["error_msg"] = "Unknown error occurred in registration!";
                                                                          echo json_encode($response);
                                                                  }
                                                          }
  
                                  }else{
                                          //invalid mobile number
                                          $response["error"] = true;
                                          $response["error_msg"] = "PLEASE ENTER VALID MOBILE NUMBER!";
                                          echo json_encode($response);
                                  }
                       /*   }else{
                                  //min of 6-charecters
                                  $response["error"] = true;
                                  $response["error_msg"] = "PASSWORD MUST BE OF MINIMUM 6-CHARACTERS!";
                                  echo json_encode($response);
                          }
                  }else{
                          // invalid email address
                          $response["error"] = true;
                          $response["error_msg"] = "invalid email address";
                          echo json_encode($response);
                  }*/
          }else{
                  //missing the required fields
                  $response["error"] = true;
                  $response["error_msg"] = "Please fill all the required parameters!";
                  echo json_encode($response);
          }
  
  ?&gt;
  </code></pre>
  
  <p><strong>form.php</strong> <strong>snippet</strong></p>
  
  <pre><code>  &lt;?php
  session_start();
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  
      &lt;title&gt;MiiSky | Dashboard&lt;/title&gt;
      &lt;script type="text/javascript" src="jquery_source"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src = "form_profile.js"&gt;&lt;/script&gt;
      &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link href="font-awesome/css/font-awesome.css" rel="stylesheet"&gt;
  
      &lt;!-- Toastr style --&gt;
      &lt;link href="css/plugins/toastr/toastr.min.css" rel="stylesheet"&gt;
  
      &lt;!-- Gritter --&gt;
      &lt;link href="js/plugins/gritter/jquery.gritter.css" rel="stylesheet"&gt;
  
      &lt;link href="css/animate.css" rel="stylesheet"&gt;
      &lt;link href="css/style.css" rel="stylesheet"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="wrapper"&gt;
          &lt;nav class="navbar-default navbar-static-side" role="navigation"&gt;
              &lt;div class="sidebar-collapse"&gt;
                  &lt;ul class="nav metismenu" id="side-menu"&gt;
                      &lt;li class="nav-header"&gt;
                          &lt;div class="dropdown profile-element"&gt;
                              &lt;!--&lt;span&gt;
                                  &lt;img alt="image" class="img-circle" src="img/sunil1.jpg" /&gt;
                              &lt;/span&gt;--&gt;
                              &lt;a data-toggle="dropdown" class="dropdown-toggle" href="#"&gt;
                              &lt;span class="clear"&gt; &lt;span class="block m-t-xs"&gt; &lt;strong class="font-bold"&gt;
                   /*here is use of session variable*/
                      &lt;?php
                      echo $_SESSION["fullname"];
                      ?&gt;&lt;/strong&gt;
                               &lt;/span&gt;
                                &lt;!--&lt;span class="text-muted text-xs block"&gt;Android Developer &lt;b class="caret"&gt;&lt;/b&gt;&lt;/span&gt;--&gt; &lt;/span&gt; &lt;/a&gt;
                              &lt;ul class="dropdown-menu animated fadeInRight m-t-xs"&gt;
                                  &lt;li&gt;&lt;a href="#"&gt;Profile&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href="#"&gt;Contacts&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href="#"&gt;Mailbox&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="divider"&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href="sign_out.php"&gt;Sign out&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;
                          &lt;/div&gt;
                          &lt;div class="logo-element"&gt;
                              MiiSky
                          &lt;/div&gt;
                      &lt;/li&gt;
  
                      &lt;li&gt;
                      &lt;a href=""&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt; &lt;span class="nav-label"&gt;Profile Vault&lt;/span&gt;&lt;span class="fa arrow"&gt;&lt;/span&gt;&lt;/a&gt;
  
  
                  &lt;/li&gt;
  
  
  
                  &lt;/ul&gt;
  
              &lt;/div&gt;
          &lt;/nav&gt;
  
          &lt;div id="page-wrapper" class="gray-bg dashbard-1"&gt;
          &lt;div class="row border-bottom"&gt;
          &lt;nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0"&gt;
          &lt;div class="navbar-header"&gt;
              &lt;a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"&gt;&lt;i class="fa fa-bars"&gt;&lt;/i&gt; &lt;/a&gt;
              &lt;form role="search" class="navbar-form-custom" action="search_results.html"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;input type="text" class="form-control" name="top-search" id="top-search"&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
              &lt;ul class="nav navbar-top-links navbar-right"&gt;
                  &lt;li&gt;
                      &lt;span class="m-r-sm text-muted welcome-message"&gt;Welcome to MiiSky&lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li class="dropdown"&gt;
  
  
  
                  &lt;li&gt;
                      &lt;a href="signin.html"&gt;
                          &lt;i class="fa fa-sign-out"&gt;&lt;/i&gt; Sign Out
                      &lt;/a&gt;
                  &lt;/li&gt;
                  &lt;!--&lt;li&gt;
                      &lt;a class="right-sidebar-toggle"&gt;
                          &lt;i class="fa fa-tasks"&gt;&lt;/i&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;--&gt;
              &lt;/ul&gt;
  
          &lt;/nav&gt;
          &lt;br&gt;&lt;div style="font-size:30px; text-align:center;"&gt;
                     /*here is use of session variable*/
                      &lt;?php
                      echo "&lt;h1&gt;Your Vault Number is generated and will be sent to your Mobile shortly.&lt;br&gt;&lt;/h1&gt;"  . $_SESSION["vault_no"];
                      ?&gt;
                      &lt;/div&gt;           
  </code></pre>