+ Reply to Thread
Results 1 to 4 of 4

Thread: php Warning: Cannot modify header information

  1. #1
    krahny's Avatar
    krahny is offline x10Hosting Member krahny is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    25

    Exclamation php Warning: Cannot modify header information

    Hey, I have this code in php:

    setcookie("remember",$_POST[username],$expire);

    This keeps appearing on the page:

    Warning: Cannot modify header information - headers already sent by (output started at /home/krahny/public_html/login.php:16) in /home/krahny/public_html/login.php on line

    I cant figure out whats wrong. Could someone help me?

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: php Warning: Cannot modify header information

    Try searching the forums. This issue has been covered many times before. Usually header() is involved, but setcookie() is just a specialized call to header().

    Make sure you understand how HTTP works. You can no more set a header once you start sending content than dial a different number while you are talking to someone on the phone (HTTP has no conference calls).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    matthew88 is offline x10Hosting Member matthew88 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    9

    Re: php Warning: Cannot modify header information

    using cookies is rough. However this header problem your running into due to the location of where the header is located

    So setting cookies must happen before the actual header which looks like below. So you must set cookies before that code section. Good luck and i hope that answered ur question. PS setting multi header things with sessions or possible cookies could create a similar error.

    <html>

    <head>

    <title></title>

    </head>

    <body>

    </body>

    </html>

  4. #4
    krahny's Avatar
    krahny is offline x10Hosting Member krahny is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    25

    Smile Re: php Warning: Cannot modify header information

    Thanks for the help, I have now solved the problem.;)

+ Reply to Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  3. Replies: 4
    Last Post: 08-11-2008, 03:12 PM
  4. Replies: 3
    Last Post: 03-10-2008, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers