setCookie 怪事,请高手出招?
我的 Code
<?
header("content-Type: text/html; charset=utf8");
session_start();
$doc_root = "..";
include_once($doc_root."/Conf/Conf.php"); // 无任何输出
include_once($doc_root."/Lib/Functions.class.php"); // 无任何输出
$fun = new FunLib();
// check user password and get basic information
// 0_login failure
// 1_login success
// 2_not manager login
$result = $fun->get_user_info($http_vars["company_no"],strtoupper($http_vars["username"]),strtoupper($http_vars["password"]));
if ($result == 1)
{
// Login success write cookie, store the company id
setCookie("company",$http_vars["company_no"],time()+3600*24*365);
echo $_COOKIE["company"]; // 这里可以拿到值
//Header("Location: $doc_root/BasicInfo/MGRF000.php");
exit;
}
?>
在其它页面拿不到值? 为什么??
<?
header("content-Type: text/html; charset=utf8");
session_start();
$doc_root = "..";
include_once($doc_root."/Conf/Conf.php"); // 无任何输出
include_once($doc_root."/Lib/Functions.class.php"); // 无任何输出
$fun = new FunLib();
// check user password and get basic information
// 0_login failure
// 1_login success
// 2_not manager login
$result = $fun->get_user_info($http_vars["company_no"],strtoupper($http_vars["username"]),strtoupper($http_vars["password"]));
if ($result == 1)
{
// Login success write cookie, store the company id
setCookie("company",$http_vars["company_no"],time()+3600*24*365);
echo $_COOKIE["company"]; // 这里可以拿到值
//Header("Location: $doc_root/BasicInfo/MGRF000.php");
exit;
}
?>
在其它页面拿不到值? 为什么??
...全文
相关推荐
PHP setcookie设置Cookie用法(及设置无效的问题)
文章中还提供了一个setcookie使用的实例,帮助开发者理解如何正确使用setcookie。在这个例子中,有两个PHP页面a.php和b.php,通过链接互相跳转。
后端setCookie问题解析[代码]
此外,setCookie属性的不生效也可能导致问题。例如,如果在setCookie时指定的路径与实际请求的路径不一致,浏览器将不会保存cookie。
php setcookie函数的参数说明及其用法
下面将详细介绍setcookie函数的各个参数以及具体的用法。1. name:这是setcookie函数的第一个参数,也是必须提供的参数。
php setcookie(name, value, expires, path, domain, secure) 参数详解
setcookie函数的定义是:`bool setcookie(string name [, string value [, int expire [, string path [, string domain
PHP setcookie() cannot modify header information 的解决方法
"PHP setcookie() 函数在尝试设置cookie时遇到‘Cannot modify header information – headers already sent’错误的解决方法"


基础编程
