我无法将一个页面上的 session 变量设置到另一个页面,我的代码如下。
首页
session_start();
header('Content-Type: application/json;charset=utf-8');
///mysql connections
while($row = mysql_fetch_array( $sthpre )){
// Print out the contents of each row into a table
$rows[] = $row;
$_SESSION['id']=$row['id'];
print json_encode($row);
}//still i get null on the other page $_SESSION['id'] = 22;
第二页
session_start();
header('Content-Type: application/json;charset=utf-8');
$row['id']=$_SESSION['id'];
print json_encode($row);
最佳答案
尝试一下:
block 引用>session_start();
session_regenerate();
header('Content-Type: application/json;charset=utf-8');
$row['id']=$_SESSION['id']; print json_encode($row);
关于php - 无法将 php session 变量设置到另一个 php 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23155018/