关于PHP网站中Session无法跨页传递

一个PHP测试网站中有两个文件login.php和main.php,login.php中的内容是:<?session_start();session_register("... 一个PHP测试网站中有两个文件login.php和main.php,login.php中的内容是:
<?
session_start();
session_register("test");
$_SESSION['test']="TEST";
echo($_SESSION['test']);
?>
main.php中的内容是:
<?
echo($_SESSION['test']);
?>

但login.php中显示TEST,而main.php中无任何显示,这是为什么?Session为什么无法跨页传递?

php.ini中关于session的设置为:
[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Whether to use cookies.
session.use_cookies = 0

;session.cookie_secure =
; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = ./

; The domain for which the cookie is valid.
session.cookie_domain =

session.cookie_httponly =
session.serialize_handler = php

session.gc_probability = 1
session.gc_divisor = 100

session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180
session.use_trans_sid = 1

; Select a hash function
; 0: MD5 (128 bits)
; 1: SHA-1 (160 bits)
session.hash_function = 0

; Define how many bits are stored in each character when converting
; the binary hash data to something readable.
;
; 4 bits: 0-9, a-f
; 5 bits: 0-9, a-v
; 6 bits: 0-9, a-z, A-Z, "-", ","
session.hash_bits_per_character = 4

; The URL rewriter will look for URLs in a defined set of HTML tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs. If you want XHTML conformity, remove the form entry.
; Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
展开
 我来答
ALLENXU_SC
2011-03-13 · TA获得超过571个赞
知道小有建树答主
回答量:184
采纳率:0%
帮助的人:155万
展开全部
要使用session必须在郑唯闭该页前面加上 session_start(); 进行接收!
另外session_register("test");是过时的用法了,强烈建山知议不要使用!在喊裂你的代码中直接删除也不影响.
leightonfz
2011-03-13
知道答主
回答量:23
采纳率:0%
帮助的人:0
展开全部
main.php也必须加入session_start();
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式