大家好,我在项目中 遇到一个十分离奇的SESSION丢失问题,有遇到这样问题的人帮我解答一下吗?就是在HTML框架里面 页面跳转以后 我依然可以取到SESEION_ID
但是跳转以后同样的ID里面存入的信息就消失了,我用SMARTY在HTML里面循环的列表页条数 中第一条用跳转的方式,里面存如的信息永远不会丢失。但是到第二条以后 ,SESSION ID还在 但是 里面的所有存入的会员 会员权限等参数全部消失。
谁能给个寻找问题的方法 或者 查找出问题 思路吗?
但是跳转以后同样的ID里面存入的信息就消失了,我用SMARTY在HTML里面循环的列表页条数 中第一条用跳转的方式,里面存如的信息永远不会丢失。但是到第二条以后 ,SESSION ID还在 但是 里面的所有存入的会员 会员权限等参数全部消失。
谁能给个寻找问题的方法 或者 查找出问题 思路吗?
上面有SESSION ID 这是登录以后 的列表页
这是通过GET传递参数以后进入的内容页,上面也有SESSIO id这是 通过返回列表页的 A标签点击返回后的内容SESSION ID 也在 但是 里面的JUR ADD等参数都消失了下面我上 列表页 和 内容页的代码
<?php
include '../includes/class_smarty.php';
include '../includes/config.php';
include_once('../wnpage/page.class.php');
session_start();
header("Cache-Control: private");
echo session_id();
echo "<p>++++++++++</p>";
echo $_SESSION['aduid'];
echo "<p>++++++++++</p>";
echo $_SESSION['jur'];
$m = new mysql();
$m->open();
mysql_query("set character_set_results=utf8");
$j = $_SESSION['jur'];
$add = $_SESSION['aduid'];
$date = date("Y-m-d h:i:s");
$data_count = 0;
$pageSize= 2;
if($add == 1){
$sql_cont = "select count(*) as c from book where bodel = 1 order by boid";
}else{
$sql_cont = "select count(*) as c from book where prid = $add and bodel = 1 order by boid";
}
$rs_cont = $m->get($sql_cont);
$data_count = mysql_result($rs_cont,0,'c');
$page_count = ceil($data_count/$pageSize);
$num = mysql_num_rows($rs_cont);
@$p = trim($_GET["page"]);
if($p=="")
{
$p = 1;
}
else
{
$p = (int)$p;
if($p<=0)
{
$p = 1;
}
elseif ($p>$page_count)
{
$p = $page_count;
}
}
$limit_page = ($p-1)*$pageSize;
switch($j){
case 1:
$sql = "SELECT book.boid,book.boname,publicationcategory.pcname,language.laname,book.bostatus,admin.adreporting_unit,book.time,admin.person,book.bodel FROM book, publicationcategory,language,admin WHERE (publicationcategory.pcid = book.pcid) and (book.prid = admin.aduid) and (book.laid = language.laid) and (book.bodel = 1) order by book.boid limit {$limit_page},{$pageSize}";
$rs = $m->get($sql);
break;
case 2:
$sql = "SELECT book.boid,book.boname,publicationcategory.pcname,language.laname,book.bostatus,admin.adreporting_unit,book.time,admin.person,book.bodel FROM book, publicationcategory,language,admin WHERE (book.prid = $add) and (publicationcategory.pcid = book.pcid) and (book.prid = admin.aduid) and (book.laid = language.laid) and (book.bodel = 1) order by book.boid limit {$limit_page},{$pageSize}";
$rs = $m->get($sql);
break;
}
$x = 0;
while($arr = mysql_fetch_array($rs)){
$list[]=array("boid"=>$arr['boid'],"boname"=>$arr['boname'],"pcname"=>$arr['pcname'],"laname"=>$arr['laname'],"bostatus"=>$arr['bostatus'],"unit"=>$arr['adreporting_unit'],"time"=>$arr['time'],"person"=>$arr['person']);
$bost = $list[$x]["bostatus"];
switch($bost){
case 0:
$bost = "未审核";
$list[$x]["bostatus"] = $bost;
break;
case 1:
$bost = "初审通过";
$list[$x]["bostatus"] = $bost;
break;
case 2:
$bost = "终审通过";
$list[$x]["bostatus"] = $bost;
break;
}
$x++;
}
//echo $_SERVER["HTTP_REFERER"];
//if(!$url){ $url=$_SERVER["REQUEST_URI"];}else{$url=$_SERVER["HTTP_REFERER"];}
$total=$data_count;
/*echo $pageSize."+++";
echo $total;*/
$b = new SmartyAissing;
$b->getArr();
if(!empty($list))
$b->getAissing("list",$list);
pageft($total,$pageSize,1,1,1,5);
$b->getAissing("pagenav",$pagenav);
$b->getWeb("archives.html");
?>内容页的代码
<?php
session_start();
echo session_id();
include '../includes/class_smarty.php';
include '../includes/config.php';
include '../wnpage/page.class.php';
$m = new mysql();
$m->open();
mysql_query("set character_set_results=utf8");
$get = $_GET['bouid'];
$sql = "SELECT book.boid,book.boname,book.pcid,publicationcategory.pcname,book.bospecification,book.bowords,book.bobodyweight,book.boisbn,language.laname,book.boauthor,book.boprice,book.bocoverweight,book.bokc,bodycolornumber.bcname,book.bopublishdate,book.bosheet,binding.biname,book.bostatus,book.bointroduction,book.botag,book.bore,book.boreason,book.bocoverpath,book.bocopyrightpath FROM book, publicationcategory,language,binding,bodycolornumber WHERE (publicationcategory.pcid = book.pcid) and (language.laid = book.laid) and (binding.biid = book.biid) and (bodycolornumber.bcid = book.bcid) and book.boid = $get ";
$rs = $m->get($sql);
$x = 0;
while($arr = mysql_fetch_array($rs)){
$list[]=array("boid"=>$arr['boid'],"boname"=>$arr['boname'],"pcid"=>$arr['pcid'],"pcname"=>$arr['pcname'],"bospecification"=>$arr['bospecification'],"bowords"=>$arr['bowords'],"bobodyweight"=>$arr['bobodyweight'],"boisbn"=>$arr['boisbn'],"laname"=>$arr['laname'],"boauthor"=>$arr['boauthor'],"boprice"=>$arr['boprice'],"bocoverweight"=>$arr['bocoverweight'],"bcname"=>$arr['bcname'],"bopublishdate"=>$arr['bopublishdate'],"bosheet"=>$arr['bosheet'],"biname"=>$arr['biname'],"bostatus"=>$arr['bostatus'],"bointroduction"=>$arr['bointroduction'],"botag"=>$arr['botag'],"bore"=>$arr['bore'],"boreason"=>$arr['boreason'],"bocoverpath"=>$arr['bocoverpath'],"bocopyrightpath"=>$arr['bocopyrightpath'],"bokc"=>$arr['bokc']);
$bost = $list[$x]["bostatus"];
switch($bost){
case 0:
$bost = "未审核";
$list[$x]["bostatus"] = $bost;
break;
case 1:
$bost = "初审通过";
$list[$x]["bostatus"] = $bost;
break;
case 2:
$bost = "终审通过";
$list[$x]["bostatus"] = $bost;
break;
}
$x++;
}
$sql_bi = "select * from binding order by biid asc";
$rs_bi = $m->get($sql_bi);
while($arr_bi = mysql_fetch_array($rs_bi)){
$list_bi[]=array("biid"=>$arr_bi['biid'],"biname"=>$arr_bi['biname']);
}
$sql_la = "select * from language order by laid asc";
$rs_la = $m->get($sql_la);
while($arr_la = mysql_fetch_array($rs_la)){
$list_la[]=array("laid"=>$arr_la['laid'],"laname"=>$arr_la['laname']);
}
$sql_pc = "select * from publicationcategory order by pcid asc";
$rs_pc = $m->get($sql_pc);
while($arr_pc = mysql_fetch_array($rs_pc)){
$list_pc[]=array("pcid"=>$arr_pc['pcid'],"pcname"=>$arr_pc['pcname']);
}
$sql_bc = "select * from bodycolornumber order by bcid asc";
$rs_bc = $m->get($sql_bc);
while($arr_bc = mysql_fetch_array($rs_bc)){
$list_bc[]=array("bcid"=>$arr_bc['bcid'],"bcname"=>$arr_bc['bcname']);
}
//echo $_SERVER["HTTP_REFERER"];
//if(!$url){ $url=$_SERVER["REQUEST_URI"];}else{$url=$_SERVER["HTTP_REFERER"];}
//$total=$data_count;
/*echo $pageSize."+++";
echo $total;*/
$b = new SmartyAissing;
$b->getArr();
if(!empty($list))
$b->getAissing("list",$list);
$b->getAissing("list_bi",$list_bi);
$b->getAissing("list_la",$list_la);
$b->getAissing("list_pc",$list_pc);
$b->getAissing("list_bc",$list_bc);
$b->getAissing("num",9);
$b->getWeb("a.html");
?>
至于浏览器缓存的问题 我也看了。 从IE8 9到 FF 到谷歌都一样 ,本人 新手 但是 谷歌还是会用的,你们上面说的那些问题,我都检查了。问题我也查到了 就是我在列表页 进入内容页的时候传递了一个BOOK的ID参数,内容页接收这个参数没问题,但是这时候返回列表也SESSION 就丢失,所以只要内容页一有这个参数SESSION内容就丢失,当我把这个参数注释掉以后 返回列表页SESSION 就还在,是我代码写的不对?还是那里有问题,请大家指点一下
你搞错了方向,自然也就找不出问题2、虽然你在 echo $_SESSION['aduid']; 时出现错误
但你也没有给出对 $_SESSION['aduid'] 赋值的代码
<?php
session_start();
include '../includes/config.php';
$_session["admin"] = null;
$m = new mysql();
$m->open();
$user = trim($_POST["user"]);
$password = trim($_POST["password"]);
$yz = trim($_POST["yz"]);
//echo $yz;
if($yz == $_SESSION['checkcode'])
{
$sql = "select * from admin where adname= '$user' and adpassword = '$password'";
$m->get($sql);
if($m->getRows()){
$n = $m->getValue(0,'adname');
$j = $m->getValue(0,'adjurisdiction');
$add = $m->getValue(0,'aduid');
$_SESSION["admin"] = $n;
$_SESSION["jur"] = $j;
$_SESSION["aduid"] = $add;
$sid = session_id();
//echo $sid;
//echo $_SESSION["admin"];
header( "Location: ../member/index.php?sid={$sid}");
//$url = "./member/index.php";
//header("location:./member/index.php");
}else{
echo "<script type='text/javascript' charset=‘gb2312’>top.location='../templates/jump.html';</script>";
}
}else{
echo "<script type='text/javascript' charset=‘gb2312’>top.location='../templates/jump.html';</script>";
}
?>
你如何能确认 $_SESSION 就一定能被赋值的
那么从此开始
另写一个程序文件
session_start();
$_SESSION["admin"] = $n; //具体的值你自己定,只要是合法的就行。下同
$_SESSION["jur"] = $j;
$_SESSION["aduid"] = $add;
$sid = session_id();
header( "Location: ../member/index.php?sid={$sid}"); 按你网站处理的流程,逐次替换跳转的 url,直到出现正确响应的 url 为止。这个 url 前一个 url 就是出现问题的地方,认真检查一下就应该找到毛病
注释掉不报错吗?另外 book.boid 是什么类型的?
$sql = "SELECT book.boid,book.boname,book.pcid,publicationcategory.pcname,book.bospecification,book.bowords,book.bobodyweight,book.boisbn,language.laname,book.boauthor,book.boprice,book.bocoverweight,book.bokc,bodycolornumber.bcname,book.bopublishdate,book.bosheet,binding.biname,book.bostatus,book.bointroduction,book.botag,book.bore,book.boreason,book.bocoverpath,book.bocopyrightpath FROM book, publicationcategory,language,binding,bodycolornumber WHERE (publicationcategory.pcid = book.pcid) and (language.laid = book.laid) and (binding.biid = book.biid) and (bodycolornumber.bcid = book.bcid) and book.boid = $get ";指这里,没有了 $get 不报错吗?
session_start();
echo session_id();
include '../includes/class_smarty.php';
include '../includes/config.php';
include '../wnpage/page.class.php';
$m = new mysql();
$m->open();
mysql_query("set character_set_results=utf8");
//$get = $_GET['bouid'];//注释 掉以后 不抱错~~~~这个 内容页接收的
而且这是注释掉 从内容页 返回列表页 不抱错 而且SESSION里面 JUR ADD等参数的赋值也都在,但是如果我不给内容页传递一个GET的数值,内容页根本没办法调用。我的列表页 的代码 我也检查了好多好多遍了 实在不看出来这一个赋值GET传递 为什么会和SESSION内的参数出问题