Results 1 to 2 of 2
  1. #1
    Join Date
    May 2005
    Location
    Voorhees, NJ
    Posts
    10

    PHP5+Cookie = Pulling My Hair Out

    I'm going nuts over this, so I'm hoping you guys can help. I've got a login script (aptly named login.php) that takes two GET parameters ( a username and password hash ).

    If everything pans out, the server sets two cookies on the client. I had this working when it was all one huge login script, but now I've broken things down into discrete objects and files, and now the cookies refuse to be sent.

    For example, the following code:
    PHP Code:
    $session = new TSession();
    setcookie("ISmellSmoke"1time()+60*60*24*30"/"".mydomain.com"0);
    $login = new TLogin();
    setcookie("ISmellFire"1time()+60*60*24*30"/"".mydomain.com"0);
    $login->Login(); 
    The cookie titled "ISmellSmoke" will be sent to the client without a problem. The cookie titled "ISmellFire" is not sent. So it appears the problem is related to

    $login = new TLogin();

    But that line produces no ouput, and no errors (that I've seen). The class has no constructor, so no other code is run.

    Any clue what the problem is?
    -jw

  2. #2
    Join Date
    May 2005
    Location
    Voorhees, NJ
    Posts
    10
    I solved it!

    First item:
    PHP Code:
    error_reporting(E_ALL); 
    ...is your best friend.

    Once I did that, I got a very nice warning telling me that the second cookie could not be sent because output had already been sent.

    The TLogin class is stored in a file named TLogin, and is required through the PHP5 autoloader.

    Each of the included files must start with <? and end with ?>

    I had made the mistake of having a single extra linefeed after the ?> which was being sent to the browser as a blank line (or possibly a space).

    Go figure. I spent nearly 2 days on this.
    -jw

Posting Permissions

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