Warning: Cannotsendsessioncookie-headersalreadysentby (outputstartedatF: php2000testphp: 2) inF: php2000testphponline4Warning: Cannotsendsessioncachelimiter-headersalr
See detailed error programs and output results
-
-
- Echo "testing ...";
- Session_start ();
- ?>
-
The output is
- Testing...
- Warning: Cannot send session cookie-headers already sent by (output started at F: php2000test. php: 2) in F: php2000test. php on line 4
- Warning: Cannot send session cache limiter-headers already sent (output started at F: php2000test. php: 2) in F: php2000test. php on line 4
Analysis:The main reason is that session is defined in php. ini. cookie is used by default.
[Session]
Session. use_cookies = 1; whether to use cookies
This statement indicates that the use of cookies to store sessions and the setting of cookies must be performed before the official htm, that is, only in the header. Therefore, if this error occurs, we modify the program:
-
- Echo "testing ...";
- Session_start ();
- ?>
The same error occurs because echo has already been output.
-
- $ I = 1;
- Session_start ();
- ?>
Running properly indicates that there can be a computing statement before session_start, but no output statement. I tried to modify it:
- Session. use_cookies = 0; whether to use cookies
But it failed. a friend who wants to know the answer will inform me how to remove the cookie-based session.