Session_start () [function. session-start]:, session
I am learning PHP. When I try to do this in session_start ()-to get the error message, I cannot send session cookies.
I have seen the problem above, but I still cannot determine my error.
What if it's wrong?
<? Php
Session_start ();
If ($ _ POST ['add'])
{
Foreach ($ _ POST ['A _ qty '] as $ k => $ v)
{
$ _ SESSION ['cart'] [$ k] = $ _ SESSION ['cart'] [$ k] + $ v;
}
}
?>
<? Php
// Look for catalog file
$ Catalogfile = "catalog. dat ";
// File is avaialbe, extract data from it and place into $ catalog, with sku as key
If (file_exists ($ catalogfile ))
{
$ Data = file ($ catalogfile );
Foreach ($ data as $ line)
{
$ LineArray = explode (":", $ line );
$ Sku = trim ($ lineArray [0]);
$ CATALOG [$ sku] ['desc'] = trim ($ lineArray [1]);
(Www.111cn.net) $ CATALOG [$ sku] ['price'] = trim ($ lineArray [2]);
}
}
Else
{
Die ("cocould not find the catalog file ");
}
?>
<Table border = "1" cellspacing = "10">
<? Php
// Print items from the catalog for selection
Foreach ($ CATALOG as $ k => $ v)
{
Echo "& lt; tr & gt; <td colspan = 2 width = 750 & gt ";
Echo "<B>". $ v ['desc']. "</B> ";
Echo "</td> </tr> ";
Echo "<tr> <td> ";
Echo "Price per unit:". $ CATALOG [$ k] ['price'];
Echo "</td> <td> Quantity :";
Echo "<input size = 4 type = text name =" a_qty [". $ k."] "> ";
Echo "</td> </tr> ";
}
?>
From: http://www.111cn.net/phper/21/2de12f9039ff28ce01ffa0e274bb51f3.htm
Can code be written like this? The online homepage displays "Warning: session_start () [functionsession-start]:
Make sure that session_start (); this function has no output before, including the header output, or remove this code, and then put php. ini (under \ php \ directory. auto_start = 0 indicates the session. auto_start = 1
Session_start () [functionsession-start]: Cannot send session cookie-headers already sent
Error Message
Warning: Cannot send session cache limiter-headers already sent
Analysis and Solutions
The reason for this problem is that when you use session_start () in the program, the actual html content is output. Maybe you said, I didn't, I just echo or
Print a message. Sorry, the output produced by your echo or print statement is the actual html content output. The solution to this problem is
Session_start () is adjusted to the first line of the program.