我直接上真实代码吧
A.php====================================
foreach($cf_map as $cf_id => $cf_info)
{
if(isset($cf_info['node_id']) || $show_cf)
{
// true => do not create input in audit log
$label=str_replace(TL_LOCALIZE_TAG,'',lang_get($cf_info['label'],null,true));
$cf_smarty .= "<tr><td {$label_css_style}> " . htmlspecialchars($label) . ":</td>" .
"<td {$value_css_style}>" .
$this->cfield_mgr->string_custom_field_value($cf_info,$id) .
"</td></tr>\n";
$cf_id_array[]=$cf_id;
$_SESSION[$cf_id]=$this->cfield_mgr->string_custom_field_value($cf_info,$id);
writeToFile("c:/test/aaa.txt",$_SESSION[$cf_id]."\n");//有值
}
B.php=======================================
$cf_id_array=$_SESSION['cf_id_array'];//有值
$smarty->assign('cf_id_array',$cf_id_array);
foreach ($cf_id_array as $idx=>$cf_id){
writeToFile("c:/test/session.txt",$cf_id.":".$_SESSION[$cf_id]."\n");//$cf_id有值,$_SESSION[$cf_id]没值
$smarty->assign('session'.$cf_id,$_SESSION[$cf_id]);
}