a.php文件
----------------------
if(!empty($pwd)){
session_start();
$_SESSION["pwd"]="$pwd";
echo "<script>window.alert('登录成功,正在转向产品展示!');window.location.href='newproduct.php';</script>";
exit;
}
else
{
echo "<script>window.alert('密码不正确,请重新输入!');window.history.back();</script>";
exit;
}
b.php文件
---------------------
session_start();
if($_SESSION["pwd"]=="")
{
echo "<script>location.href='mlogin.php';</script>";
exit;}
session这样写在本机测试是可以的,但是放到服务器上,用三级域名测试session就丢失了。
在session_start();前加上session_id(SID),就出现不用输入密码直接访问的情况了。哪位高手指点一下,应该怎样修改?
----------------------
if(!empty($pwd)){
session_start();
$_SESSION["pwd"]="$pwd";
echo "<script>window.alert('登录成功,正在转向产品展示!');window.location.href='newproduct.php';</script>";
exit;
}
else
{
echo "<script>window.alert('密码不正确,请重新输入!');window.history.back();</script>";
exit;
}
b.php文件
---------------------
session_start();
if($_SESSION["pwd"]=="")
{
echo "<script>location.href='mlogin.php';</script>";
exit;}
session这样写在本机测试是可以的,但是放到服务器上,用三级域名测试session就丢失了。
在session_start();前加上session_id(SID),就出现不用输入密码直接访问的情况了。哪位高手指点一下,应该怎样修改?
b页面的session_start();
下面加上print_r($_SESSION);
能得到结果吗?
a.php文件
----------------------
if(!empty($pwd)){
session_start();
$_SESSION["pwd"]="$pwd";
print_r($_SESSION);
die;
echo " <script>window.alert('登录成功,正在转向产品展示!');window.location.href='newproduct.php'; </script>";
exit;
}
else
{
echo " <script>window.alert('密码不正确,请重新输入!');window.history.back(); </script>";
exit;
} 保存成功
如果成功則:
b.php文件
---------------------
session_start();
print_r($_SESSION);
die;
if($_SESSION["pwd"]=="")
{
echo " <script>location.href='mlogin.php'; </script>";
exit;} 如果沒有SESSION,則可能是其它情況,如:檢查是否是同一個域名下
test1.php<?php
session_start();
$_SESSION["test"]='test_str';
echo " <script>window.location.href='test2.php'; </script>";
?>test2.php<?php
session_start();
print_r($_SESSION);
?>
可是没写过cookie,能不能给个样板,像这个session一样,写入和获取的
setcookie("cookie_Name",$HTTP_POST_VARS['cookie_Value']);
//读
$coolie_Value = $HTTP_COOKIE_VARS['cookie_Value'];