1.php如下:<?php
if (!isset($_SESSION)) {
session_start();
}
$_SESSION["swhowimg"] = "allen";
?>
2.php如下:
<?php
if (!isset($_SESSION)) {
session_start();
}
print $_SESSION["swhowimg"];
?>先打开1.php显示值allen,后打开2.php却提示错误:Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 6
PHP Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 6 还请各位帮小弟看看,是不是php环境哪配好?
if (!isset($_SESSION)) {
session_start();
}
$_SESSION["swhowimg"] = "allen";
?>
2.php如下:
<?php
if (!isset($_SESSION)) {
session_start();
}
print $_SESSION["swhowimg"];
?>先打开1.php显示值allen,后打开2.php却提示错误:Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 6
PHP Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 6 还请各位帮小弟看看,是不是php环境哪配好?
是否是你的session保存路徑有問題呢?
session.save_path = "c:\temp"
session.auto_start = 1
去掉if(!isset($_SESSION))判断提示:Notice: A session had already been started - ignoring session_start() in D:\site\dianphp\agent\2.php on line 2
最好不要让其自动开始session程序前面:
session_save_path("你站点下某个可读写的目录");
session_start();
<?php
session_start();
$_SESSION['swhowimg'] = "sadf";
?>
<a href="2.php">2.php</a>2.php
<?php
session_start();
echo $_SESSION['swhowimg'];
?>
用到 session 都要 session_start();
<?php
session_start();
$_SESSION["swhowimg"] = "allen";
print $_SESSION["swhowimg"];
?>
<a href="2.php">2.php</a>2.php
<?php
session_start();
echo $_SESSION['swhowimg'];
?>
现在按上面的测试,还是提示没有定义的,没有值:
Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 7
PHP Notice: Undefined index: swhowimg in D:\site\dianphp\agent\2.php on line 7