以下在IE8 和360浏览器下运行。
1、为何刷新同一页面,每次都生成新的session文件?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your titile</title>
</head>
<body>
<?php
session_start();
$_SESSION['boy']=true;
$_SESSION['age']=18.5;
?>
</body>
</html>
2、在页面1保存session值后,在不关闭页面的情况下,新开1个标签页打开页面2却无法读取页面1保存的session值?01.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your titile</title>
</head>
<body>
<?php
session_start();
$_SESSION['boy']=true;
$_SESSION['age']=18.5;
?>
</body>
</html>02.php
<?php
session_start();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";?>
1、为何刷新同一页面,每次都生成新的session文件?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your titile</title>
</head>
<body>
<?php
session_start();
$_SESSION['boy']=true;
$_SESSION['age']=18.5;
?>
</body>
</html>
2、在页面1保存session值后,在不关闭页面的情况下,新开1个标签页打开页面2却无法读取页面1保存的session值?01.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your titile</title>
</head>
<body>
<?php
session_start();
$_SESSION['boy']=true;
$_SESSION['age']=18.5;
?>
</body>
</html>02.php
<?php
session_start();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";?>
前面不能有任何的页面输出
看一下结果
我感觉echo ini_get('session.auto_start');意义不大,加入后无显示,而且我在php.ini中已置1,更何况session_start()作用等同吧!to u010419124 :session.use_trans_sid 已置1,结果无变化。郁闷...
2.确认#1和#4说的情况
那 session_start() 还有什么用?
你去掉 session_start() 就正常了
session_start();
$_SESSION['boy']=true;
$_SESSION['age']=18.5;
echo session_id();
?>取到这个session_id后在 访问页面二 index2.php?sid= 这个值
在页面2<?php
session_id($_GET['sid']);
session_start();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";?>
请大神指教!