Session_start () [function. session-start]:, session

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.