<分区>
我需要在我的页面中设置 cookie,但它返回
Warning: Cannot modify header information - headers already sent by (output started at /home1/bsam/public_html/24kadr/index.php:1) in /home1/bsam/public_html/24kadr/basic_login.php on line 35
在第一行我有
include 'basic_login.php';
但即使我删除了 include,ir 也会在 session_start 或 mysql_connect 上返回相同的警告。 所以我认为这些所有函数在调用时都使用 header ,但我该怎么办?至少我需要连接到数据库,然后我需要使用 setcookie()。 那我该怎么办? 谢谢
更新index.php的第一行
<?include 'basic_login.php';include 'settings.php';?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
...........
在 basic_login.php 中开始
<?
session_start();
include 'connect.php';
ini_set("session.bug_compat_42",1);
ini_set("session.bug_compat_warn",0);
............................................
setcookie("cookname", $_SESSION['username'], time()+60*60*24*30, "/");
setcookie("cookpass", $_SESSION['password'], time()+60*60*24*30, "/");