Server returns null in android phone but right data in ios simulator

Hi,

I have created login and after login i get the stats via getstats.php…

After login, in the next page i get data successfully in ios simulator but in android phone it is getting null.

Here json reply log in android -

res: {"F":null,"W":null,"T":null,"Fp":null,"Wp":null,"Tp":null,"msg":"Invalid","sid":null}

And in Ios Simulator -

res: {"F":"135","W":"1","T":"1","Fp":"1","Wp":"1","Tp":"1","msg":"success","sid":"1nf9ecj3j2nmm2lmamblf27n34"}

the same server code is returning success in ios simulator and invalid via android…

in login.php i set session id (sid)-

      $postdata = file_get_contents("php://input");
parse_str($postdata, $get_array);

 //print_r($get_array);
 
 
 $id = $get_array['id']; 
 $pass = $get_array['pass']; 
 
 
$link = mysqli_connect("localhost", "aaa", "aaa", "aa");
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
    
    echo ("connection failed");
}
 
// Attempt select query execution
$sql = "SELECT `uid` FROM userdetails WHERE uname = '$id' AND pass = '$pass'";
//$query = mysql_query($sql);

$msg;

if($query = mysqli_query($link, $sql)){
if (mysqli_num_rows($query) >= 1)
{
     while($row = mysqli_fetch_assoc($query)) {
         
        $value = $row['uid'];
        
     }
     
     
	session_start();
    $a = session_id();
    
    $_SESSION['sid'] = $a;
    $_SESSION['userid'] = $value;
    $_SESSION['name'] = $id;
   
	
	$msg = "success";
	    }
       
    else{
    
    
        $msg = "fail";
    
    }
  }
  
  else
{
    $msg = "dberror";
}



header('Content-type: application/json');
$data2 = array('sid' => $a ,'msg' => $msg);
echo json_encode($data2);
 
// Close connection
//mysqli_close($link);


?>

2nd page - getstats.php - i sent session id generated in login via POST to getstats.php as sid

 <?php

//gettrees

session_start();




$postdata = file_get_contents("php://input");
parse_str($postdata, $get_array);

 //print_r($get_array);
 
 $msg;
 $sesid = $get_array['sid']; 
$serverid = $_SESSION['sid'];


if($_SESSION['sid'] == $sesid)
 
 {

$link = mysqli_connect("localhost", "aaa", "aaa", "aa");
 
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
 
  $userid =  $_SESSION['userid'];
 
//  echo "uuuuuuuuuuuuuuuuuuuu";
//  echo $userid;
 
 
// Attempt select query execution
$sql = "SELECT `F`,`W`,`T`,`Fp`,`Wp`,`Tp` FROM groupdetails WHERE uid='$userid'";
//$query = mysql_query($sql);


if($query = mysqli_query($link, $sql)){
if (mysqli_num_rows($query) > 0)  
{  
    while($row = mysqli_fetch_assoc($query)) {
    
    
     $F = $row['F'];
     $W = $row['W'];
     $T = $row['T'];
     $Fp = $row['Fp'];
     $Wp = $row['Wp'];
     $Tp = $row['Tp'];
    }
    $msg = "success";
    
}
    else
    {
        $msg = "No Records";
    }
} 

else
{
    $msg = "db error";
}
     
  
}
  else
  {
      $msg = "Invalid";
      
  }


 
 $dir = "../imgs/";
 $list = array();
 
// Open a directory, and read its contents
if (is_dir($dir)){
  if ($dh = opendir($dir)){
    while (($file = readdir($dh)) !== false){
        if ($file == "." or $file == "..") continue;
        $list[] = $file;
     // echo $file;
    }
    closedir($dh);
  }
}

 header('Content-type: application/json');
 $data2 = array( 'F' => $userid, 'W' => $W, 'T' => $T, 'Fp' => $Fp, 'Wp' => $Wp, 'Tp' => $Tp, 'list' => $list, 'msg' => $msg , 'sid' => $serverid );
 echo json_encode($data2);
 
// Close connection
mysqli_close($link);


?>

$_SESSION[‘sid’] or $serverid return null in android phone but right value from ios simulator.

cpp code -

    std::string ss = cocos2d::UserDefault::getInstance()->getStringForKey("sid");


// Http

HttpRequest* request = new HttpRequest();
request->setUrl("http://www.tes.com/getstats.php");
request->setRequestType(HttpRequest::Type::POST);
std::vector<std::string> headers;
headers.push_back("Content-Type: application/json; charset=utf-8");
request->setHeaders(headers);

std::string postData = "sid=" + ss;

request->setRequestData(postData.c_str(), postData.length());
request->setTag("POST test2");

request->setResponseCallback( [=] (network::HttpClient* client, network::HttpResponse* response) {
    if (!response)
    {
        return;
    }
    
    
    if (0 != strlen(response->getHttpRequest()->getTag()))
    {
        log("%s completed", response->getHttpRequest()->getTag());
    }
    
    long statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag());
    log("response code: %ld", statusCode);
    
    if (!response->isSucceed())
    {
        log("response failed");
        log("error buffer: %s", response->getErrorBuffer());
           return;
    }
    
    
    if (response->isSucceed()) {
        log("Get success");
        
        std::vector<char>* buffer = response->getResponseData();
        std::string res;
        res.insert(res.begin(), buffer->begin(), buffer->end());
        log("res: %s", res.c_str());
       
        rapidjson::Document d;
        d.Parse<0>(res.c_str());
}

Please help. Thank you

$_SESSION['sid']; return NULL from getstats page, so on first page

 $a = session_id();
 $_SESSION['sid'] = $a;

it is not assigning session id to session variable only when i call from android phone, but from ios simulator it works.

Anyone… I am really stuck here…