问session的问题
php 4.0.4
=================================================================
<html>
<head><title>test.php</title></head>
<body>
<?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
echo("count has not set before");
} else {
$_SESSION['count']++;
echo("count has already set.");
}
echo($_SESSION['count']);
?>
</body>
</html>
=========================================================================
Warning: Cannot send session cookie - headers already sent by (output started at E:\wwwroot\proj2\test.php:4) in E:\wwwroot\proj2\test.php on line 5
Warning: Cannot send session cache limiter - headers already sent (output started at E:\wwwroot\proj2\test.php:4) in E:\wwwroot\proj2\test.php on line 5
Warning: open(/tmp\sess_7c11d74bebe81cd196e2c4fa87fcfc8d, O_RDWR) failed: m (2) in E:\wwwroot\proj2\test.php on line 5
count has not set before0
Warning: open(/tmp\sess_7c11d74bebe81cd196e2c4fa87fcfc8d, O_RDWR) failed: m (2) in Unknown on line 0
Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
是不是php.ini没有设置好?
问题点数:100、回复次数:5Top
1 楼KLSD(John)回复于 2003-05-01 11:36:29 得分 0
session.save_path应该设成什么样子啊?
Top
2 楼KLSD(John)回复于 2003-05-01 11:39:55 得分 0
还有,第一第二个warning究竟是什么意思?
Top
3 楼youbest(冲天飞豹)回复于 2003-05-01 12:04:05 得分 0
改成
<?php
session_start();
?>
<html>
<head><title>test.php</title></head>
<body>
<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
echo("count has not set before");
} else {
$_SESSION['count']++;
echo("count has already set.");
}
echo($_SESSION['count']);
?>
</body>
</html>
然后,你在PHP的目录下建立一个tmp这样的目录.
应该就可以了.Top
4 楼qxj82()回复于 2003-05-01 15:21:19 得分 100
session_start()前不要往buffer里写东西Top
5 楼bombshell(水中鱼)回复于 2003-05-01 16:32:53 得分 0
<html>
<head><title>test.php</title></head>
<body>
<?php
ob_start();
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
echo("count has not set before");
} else {
$_SESSION['count']++;
echo("count has already set.");
}
echo($_SESSION['count']);
ob_end_flush();
?>
</body>
</html>
Top




