cookies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alain Dhaene

    cookies

    hi,

    I have following problem.

    I have a form wich I post to another php file there i want to store the data
    form the form in a cookie.
    code:

    <?

    foreach ($HTTP_POST_VAR S as $key => $value) {



    if($value=='ON' )


    {


    setcookie("Test Cookie","$key", time()+3600);

    }



    But it doens'n work. I have the following Error Warning: Cannot modify
    header information - headers already sent by (output started at C:\Program
    Files\Apache Group\Apache2

    I understand the error and i have search in de tutorial form php.net, but
    How can I handle this problem?



    Thanks,



    Alain




  • Dan Tripp

    #2
    Re: cookies

    Alain Dhaene wrote:
    [color=blue]
    > hi,
    >
    > I have following problem.
    >
    > I have a form wich I post to another php file there i want to store the data
    > form the form in a cookie.
    > code:
    >
    > <?
    >
    > foreach ($HTTP_POST_VAR S as $key => $value) {
    >
    >
    >
    > if($value=='ON' )
    >
    >
    > {
    >
    >
    > setcookie("Test Cookie","$key", time()+3600);
    >
    > }
    >
    >
    >
    > But it doens'n work. I have the following Error Warning: Cannot modify
    > header information - headers already sent by (output started at C:\Program
    > Files\Apache Group\Apache2
    >
    > I understand the error and i have search in de tutorial form php.net, but
    > How can I handle this problem?
    >
    >
    >
    > Thanks,
    >
    >
    >
    > Alain
    >
    >
    >
    >[/color]

    You must set cookies before sending any other output to the browser...
    including spaces, line feeds, etc.

    Move your code that does cookies to the top of your PHP file. Maybe
    that'll help ya.

    Regards,

    - Dan

    Comment

    Working...