title: how to trace and rectify a session lost error during AJAX call and response?
body: <p>I am not getting my " $uid " entered into my database.In everypage there is session_start() . The session_uid inside session.php which is called and included in "includes.php" .This is included in every page of codes using</p>
  
  <pre><code>  include_once"includes.php";
  </code></pre>
  
  <p>Only this ajax call has this issue , rest ajax functions ae working fine in the same project, which is find very tricky. </p>
  
  <p>Here is the jquery ajax code i use : </p>
  
  <pre><code>$(document).ready(function(){
  
        $("#update_button").click(function()
       {
             var updateval = $("#update").val();
  
  
              var cate=$("#selectcategory").val();
              //var up=$("#uploadvalues").val();
  
  
  
               var dataString = 'update='+updateval+'&amp;Category='+cate;
               if($.trim(updateval).length==0)
                   {
                     alert('ENTER SOME TEXT!!');
                   }
               else
                   {
  
            $.ajax({
                       type: "POST",
                       url: $.base_url+"message_ajax.php",
                       data: dataString,
                       cache: false,
                       success: function(html)
                     {
  
                          $("#update").val('').focus();
  
                           $('#selectcategory').val('');
                        //var c=$('#update_count').html();
                       //$('#update_count').html(parseInt(c)+1);
  
                       $('#my-awesome-dropzone').hide();
                       }
                    });
  
                   //$('#imageupload').slideUp('slow');
                    }
                   return false;
                     }); 
  
                  });
  </code></pre>
  
  <p>message_ajax.php : </p>
  
  <pre><code>               &lt;?php
  
                      //Load latest update 
                    include_once 'includes.php';
  
                   if(isSet($_POST['update']))
                    {
  
  
                   $update=mysqli_real_escape_string($db,$_POST['update']);
                  //$uploads=$_POST['uploads'];
  
             //Additional field 
                 $cat=mysqli_real_escape_string($db,$_POST['Category']);
                //$pvt= $_POST['privacyoptions'];  
  
  
                   //new category option
                $data=$obje-&gt;Updates_insert($uid,$update,$cat);
                if($data)
                      {
                             include("posts.php");
                      }
                     }
                 ?&gt;
  </code></pre>
  
  <p>The class file in which the function is defined</p>
  
  <pre><code>                class BasicFile{
  
  
               public function Updates_insert($uid,$update,$cat)
                {
                   date_default_timezone_set('Asia/Kolkata');
             //echo date('m d G:i:s GMT+5.30 Y');
  
               $posts=mysqli_real_escape_string($this-&gt;db,$update);
               $cate=mysqli_real_escape_string($this-&gt;db,$cat);
  
                  $t=time();
  
                        $da=date("M d Y H:i:s");
  
  
              $g=mysqli_query($this-&gt;db,"SELECT `username`,`appid`,`profile_pic`,`first_name`,`last_name`,`Class_Dept`,`CollegeName` FROM `users` WHERE `uid`='$uid'") or die(mysqli_error($this-&gt;db)); 
  
              while($det =mysqli_fetch_array($g))
               { 
                $first_name = $det['first_name'];
                $username = $det['username'];
                $last_name = $det['last_name'];
                $app_id= $det['appid'];
                $CollegeName = $det['CollegeName'];
  
                $Class_Dept = $det['Class_Dept'];
                $profilepic= $det['profile_pic'];
             } 
                $name=$first_name.''.$last_name;
                $cont="image";
                    //mysqli_query($this-&gt;db,"INSERT INTO `CommonData`(`content`,`uid`,`category`)VALUES(N'$posts','$uid','$cate')");
                   mysqli_query($this-&gt;db,"INSERT INTO `CommonData`(`content`,`uid`,`appid`,`username`,`class`,`collegename`,`contenttype`,`name`,`category`,`like`,`remark`,`time`,`date`,`profilepic`)VALUES(N'$studentposts','$uid','$app_id','$username','$Class_Dept','$CollegeName','$cont','$name','$cate',0,0,'$t','$da','$profilepic')");
                  mysqli_query($this-&gt;db,"INSERT INTO `NotificationData`(`content`,`uid`,`appid`,`notificationtype`,`username`,`name`,`class`,`collegename`,`category`,`contenttype`,`date`,`profilepic`)VALUES(N'$studentposts','$uid','$app_id','post','$username','$name','$Class_Dept','$CollegeName','$cate','$cont','$da','$profilepic')");
   return true;
  
                      }
                }
  </code></pre>
  
  <p>includes.php </p>
  
  <pre><code>            //ob_start("ob_gzhandler");
            error_reporting(0);
               session_start();
         include_once 'includes/db.php';
         include_once 'includes/Updates.php';
            include_once 'includes/textlink.php';
            include 'includes/htmlcode.php';
          include 'includes/nameFilter.php';
           include 'includes/imageCheck.php';
          include 'includes/Wall_Expand.php';
           $obje = new BasicFile($db);
            include_once 'session.php';
  
         include 'configurations.php';
  
          /* Session Data */
               include('user_session_data.php');
  
  
             $url404=$base_url.'404.php';
            $index_url=$base_url.'login.php';
  </code></pre>
  
  <p>session.php </p>
  
  <pre><code>                &lt;?php 
                     $session_uid=$_SESSION['uid']; 
               // Session Private
              if(!empty($session_uid))
              {
                    $uid=$session_uid;
                     //$usertype=session_user; 
  
  
  
                           $login='1';
                    }
                      ?&gt;
  </code></pre>