Thread: Cookies

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

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    First I set a cookie, then whenever someone visits the site I check the MySQL DB to see if they have a cookie, if they do then it updates the users row in the DB.

    But...I set a cookie and when they come back they get another cookie eg:

    cookie:anyuser@musicgoeson.com
    and then they get another cookie:
    cookie:somethingelse@musicgoeson.com

    why?

    Girish Gupta
    webmaster@musicgoeson.com

    [This message has been edited by girish_gupta (edited July 16, 2000).]
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Girish ,

    how you are setting?..if you post that code portion then we can help you out what is gone wrong..

    cookie eg:

    setcookie("cookiename","cookie value",time()+14400,"/","www.yourdomain.com");



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    Here's the code I use:


    $result = mysql_query ("SELECT * FROM cookie WHERE userid = '$CookieID'");

    if ($row = mysql_fetch_array($result))
    {
    mysql_query ("UPDATE cookie set last_visit = '$date | $time GMT', user_agent = '$HTTP_USER_AGENT', remote_host = '$REMOTE_HOST', remote_addr = '$REMOTE_ADDR' WHERE userid = '$CookieID';");
    }
    else
    {
    mysql_query ("INSERT INTO cookie (name, email, last_visit, user_agent, referrer, remote_host, remote_addr) VALUES ('$name', '$email', '$date | $time GMT', '$HTTP_USER_AGENT', '$HTTP_REFERER', '$REMOTE_HOST', '$REMOTE_ADDR')");

    setcookie("CookieID", mysql_insert_id(), time()+94608000, "/");
    }

    Girish Gupta
    webmaster@musicgoeson.com
  6. #4
  7. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    setcookie("CookieID", mysql_insert_id(), time()+94608000, "/");
    >>


    girish ,

    You are not using the 5th argument(ie,'www.yourdomain.com'),that is why your cookie won't available through out your site..

    setcookie("CookieID", mysql_insert_id(), time()+94608000, "/","www.musicgoeson.com");


    other things seems fine i suppose..





    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

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

IMN logo majestic logo threadwatch logo seochat tools logo