Home  >  Article  >  Backend Development  >  PHP中的session不能跨页传送?一跨页就丢失,为空的

PHP中的session不能跨页传送?一跨页就丢失,为空的

WBOY
WBOYOriginal
2016-06-13 12:38:21848browse

PHP中的session不能跨页传递?一跨页就丢失,为空的!

本帖最后由 MoreQuestion 于 2011-03-20 07:57:23 编辑 如先浏览a.php文件,里边写入一个会话值。

再浏览b.php,得到a.php写入的会话值。为空!

为什么呢?在本地机器上测试非常正常。一上传服务器就完了。

PHPINFO的session信息

session.save_path D:/hosting/user/html/temp D:/hosting/user/html/temp 

这个文件夹可读可写。

当浏览a.php页时,产生一个有大小的文件,也保存了会话值。
当浏览b.php页时,产生一个大小为0的文件。拿不到?什么原因?

<br />
session<br />
Session Support  enabled  <br />
Registered save handlers  files user  <br />
Registered serializer handlers  php php_binary wddx  <br />
<br />
Directive Local Value Master Value <br />
session.auto_start Off Off <br />
session.bug_compat_42 On On <br />
session.bug_compat_warn On On <br />
session.cache_expire 180 180 <br />
session.cache_limiter nocache nocache <br />
session.cookie_domain no value no value <br />
session.cookie_httponly Off Off <br />
session.cookie_lifetime 0 0 <br />
session.cookie_path / / <br />
session.cookie_secure Off Off <br />
session.entropy_file no value no value <br />
session.entropy_length 0 0 <br />
session.gc_divisor 100 100 <br />
session.gc_maxlifetime 1440 1440 <br />
session.gc_probability 1 1 <br />
session.hash_bits_per_character 4 4 <br />
session.hash_function 0 0 <br />
session.name PHPSESSID PHPSESSID <br />
session.referer_check no value no value <br />
session.save_handler files files <br />
session.save_path D:/hosting/user/html/temp <br />
session.serialize_handler php php <br />
session.use_cookies On On <br />
session.use_only_cookies Off Off <br />
session.use_trans_sid 1 1 <br />
<br />


a.php
<?php<br />
session_start();<br />
?><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>session set</title><br />
</head><br />
<br />
<body><br />
<?php<br />
$_SESSION['session_value'] = 'value';<br />
var_dump($_SESSION);<br />
phpinfo();<br />
?><br />
</body><br />
</html>

这个文件正常,可以打印出会话值。

b.php
<?php <br />
session_start();<br>
?><br>
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn