Web Hosting Forums

Results 1 to 4 of 4

This is a discussion on Cookies and Milk in the Hosting Talk & Chit-chat forum
Can someone help? For the life of me I can't set a cookie. I keep getting header problems. I'm trying to use setCoookie("voteCookie", 1, time()+3600) ...

  1. #1
    Loyal Client
    Join Date
    Aug 2001
    Posts
    7

    Cookies and Milk

    Can someone help? For the life of me I can't set a cookie. I keep getting header problems.

    I'm trying to use

    setCoookie("voteCookie", 1, time()+3600)

    so it expires in hour.

    HELP!

  2. #2
    Loyal Client
    Join Date
    Aug 2001
    Posts
    70
    you can't send out ANY data other than headers before you try to set a cookie. i.e. no HTML AND no whitespace before the first <?php in your PHP file or any included files. if you do, you'll get header errors. so that might be your problem.

  3. #3
    Loyal Client
    Join Date
    Aug 2001
    Posts
    7
    If that is the case ... then that is a problem;

    Thanks for the input... i'll try some stuff.

  4. #4
    E.Z
    E.Z is offline
    Loyal Client
    Join Date
    Oct 2002
    Posts
    54
    You can set PHP to work in buffered more then you can set headers anywhere in the script.

    The best way to do it is by setting the output buffering options in PHP.INI, that way you don't have to do anything in the script. But even without access to PHP.INI you can work with output buffering by calling a function in the beginning of the script and again in the end.

    For more information see: http://www.php.net/manual/en/ref.outcontrol.php

    E.Z

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •