title: Undefined variable: _SESSION in php?
body: <p>I have to php files and want to send the $_lang to the other page by using session, whether i use session_start() in both file or just only in the first file the $_lang can not be sent. I have same problem if i use cookie</p>
  
  <p>js file:</p>
  
  <pre><code>$(document).ready(function(){
  cat();
  function cat(){
      $.ajax({
          url:    "action.php",
          method: "POST",
          data:     {menu:1},
          success: function(data){
              $("#get_menu").html(data);
  
          }
      })
  }
  
  });
  </code></pre>
  
  <p>first php file:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  //get current url
  $goback=$_SERVER['HTTP_REFERER'];
  $GLOBALS['_lang']=$_GET['lang'];
  $_SESSION['lang']=$_lang;
  echo $_SESSION['lang'];
  
  //go to current url
  header("location:$goback");
  
  
  ?&gt;
  </code></pre>
  
  <p>here is the code for second file.</p>
  
  <pre><code> &lt;?php
  
   include ('db.php');
  
   $_lang=$_SESSION['lang'];
  
  
   //$_lang= 'us';
   if(isset($_POST["menu"])){
  //function display_menu(){
  
  $category_query="SELECT * FROM menu WHERE parent_id=0";
  $run_query=mysqli_query($con,$category_query);
  
  if(mysqli_num_rows($run_query)&gt;0){
      while($row=mysqli_fetch_array($run_query)){
          $menu_id=$row["menu_id"];
          $menu_name=$row[$_lang];
          $menu_icon=$row["icon"];
          ...
  </code></pre>