#1
  1. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    Hi,
    i'm having a problem with my setcookie() instructions.
    Although there are absolutely
    no html tags in front of them,
    for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"...

    I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension.

    At the beginning of each files there's a Could the cookie failure and the include functions be related ?
    In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail

    what am i doing wrong ???

    thanks for any help
    nick

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    45
    Rep Power
    15
    You said you were wiping out tags in echo commands...you can't output ANYTHING before you call setcookie. This includes echos. Since includes/requires do include that code in your script, you can't have anything being output in your includes either. As soon as something is sent to output, a header is set, thereby making your setcookie invalid. Setcookie must be something you do before anything else.
  4. #3
  5. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    THanks for the tip polman....
    in most cases tho, i have set the cookie expiry as follows:

    $extratime=24*60*90; //sets cookie for 3 months

    then
    setcookies (..., time()+$extratime, .....);

    this seems to have worked so far....
  6. #4
  7. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    oops sorry polman hadn't noticed your post wasn't the same as your email ;p

    thanks a lot for both tips..... I was indeed using print and echo to debug my script, and had suspected that that might be the problem...

    well, now i know that's the problem ;p
    i'll try that out now.... thanx a lot for your help ;p

    nick

Similar Threads

  1. cant delete cookies random errors
    By toxical in forum PHP Development
    Replies: 2
    Last Post: November 26th, 2003, 06:16 AM
  2. Clearing all cookies php script - HowTo?
    By fordfasterr in forum PHP Development
    Replies: 8
    Last Post: October 24th, 2003, 10:40 AM
  3. Problem with lwp and cookies
    By vinaykakade in forum Perl Programming
    Replies: 1
    Last Post: August 13th, 2003, 11:07 AM
  4. Problems setting cookies with a path and domain
    By IBBoard in forum PHP Development
    Replies: 4
    Last Post: July 2nd, 2003, 04:03 PM
  5. AOL cookies?
    By cfthong in forum PHP Development
    Replies: 0
    Last Post: August 18th, 2000, 11:59 AM

IMN logo majestic logo threadwatch logo seochat tools logo