SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $HTTP_COOKIE_VARS question

    Hi,

    I have a line of code in my program as follows:
    $username = $HTTP_COOKIE_VARS["myusername"];

    From time to time, it fails to return a value.

    I am storing the cookie as follows:
    setcookie ("username", $myusername,time()+999999);

    Can anyone tell me how I can avoid this happening?

    I tried to change the code as follows but still the same:
    $username = $_COOKIE["myusername"];


    Your help will be greatly appreciated.
    Last edited by surfinglight; Jun 17, 2005 at 02:59.

  2. #2
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does $username always have a value?

  3. #3
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yes.

    Yes.

    System accepts it from user input, and set cookie accordingly.

    But when retrieved, sometimes it returns blank.

    I don't see why.

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by surfinglight
    Hi,

    I have a line of code in my program as follows:
    $username = $HTTP_COOKIE_VARS["myusername"];

    From time to time, it fails to return a value.

    I am storing the cookie as follows:
    setcookie ("username", $myusername,time()+999999);

    Can anyone tell me how I can avoid this happening?

    I tried to change the code as follows but still the same:
    $username = $_COOKIE["myusername"];


    Your help will be greatly appreciated.

  5. #5
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good catch, Stereo.


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
  •