数据存储在Session中但是当在其他php文件中获取某些对象时为null

On the original where I stored the data in session array, all data are complete when I fetch it but when I call that session on the other some data is null or undefined.

I don't know what I'm going to do, please help

Edit: In original file

$query = $dbh->prepare("Select p.start_date,p.end_date,dfp.id,dfp.product_id
      dfp.type,dfp.quantity_required,dfp.less,pd.unit,pd.name
      from promo p
      inner join discounts_free_products dfp                        
      on p.id=dfp.promo_id                        
      inner join products pd                        
      on dfp.product_id=pd.id                       
      where DATE(p.end_date) >= DATE(NOW()) 
");
$query->execute();
$count=0;
$queryresult_set=array();
$queryresult_set=$query->fetchAll();
$count=count($queryresult_set); 
$_SESSION['COUNT_PROMO']= $count;
$_SESSION["PROMO_PRODUCTS"]=$queryresult_set;

In other php file

foreach($_SESSION["PROMO_PRODUCTS"] as $result) { 
    $pc_list[] = $result["product_id"]; 
    $d_id=$result['id']; 
} 

error:Undefined index: product_id

PHP 5 Session

A session is started with the session_start() function.

Session Create

<?php
    // Start the session
    session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
    // Set session variables
    $_SESSION["favcolor"] = "green";
    $_SESSION["favanimal"] = "cat";
?>

</body>
</html>

To retrieve session on another page

<?php
    session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
    // Echo session variables that were set on previous page
    echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";
    echo "Favorite animal is " . $_SESSION["favanimal"] . ".";
?>

</body>
</html>

You probably forgot to add session_start(); at the beginning of your file(s). This was the most common issue when I started. But without your code, nobody here can help you.


Edit: Are you sure you have:
original.php

session_start();
$query = $dbh->prepare("Select p.start_date,p.end_date,dfp.id,dfp.product_id
          dfp.type,dfp.quantity_required,dfp.less,pd.unit,pd.name
          from promo p
          inner join discounts_free_products dfp                        
          on p.id=dfp.promo_id                        
          inner join products pd                        
          on dfp.product_id=pd.id                       
          where DATE(p.end_date) >= DATE(NOW()) 
");
$query->execute();
$count=0;
$queryresult_set=array();
$queryresult_set=$query->fetchAll();
$count=count($queryresult_set); 
$_SESSION['COUNT_PROMO']= $count;
$_SESSION["PROMO_PRODUCTS"]=$queryresult_set;

And in other.php

session_start();
foreach($_SESSION["PROMO_PRODUCTS"] as $result) { 
        $pc_list[] = $result["product_id"]; 
        $d_id=$result['id']; 
} 

Edit
Try:

session_start();
foreach($_SESSION["PROMO_PRODUCTS"] as $result) {
    if (isset($_SESSION["PROMO_PRODUCTS"]))
       if ($_SESSION["PROMO_PRODUCTS"] != NULL){
          $pc_list[] = $result["product_id"]; 
          $d_id=$result['id']; 
          echo $_SESSION["PROMO_PRODUCTS"];                   
       }
    }
}

Maybe you have the cookie but miss to fill it somewhere else. This is from <a href="http://stackoverflow.com/questions/18731693/undefined-index-with-php-sessions">here</a>.