SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie doesn't update its value

    Hi...

    I'm new working with PHP and I've a problem with cookies...

    Well, I've a textbox where users have to enter the number of a quotation. After they enter the value and press enter, I call a php file where I check if the quotation exist, if it doesn't exists I send a message explain that it doesn't exist, if it exists I set a cookie, and I need to update two others cookies that where created before with new values but these don't update. I try to expire them with "time()-3600" before update them, but it doesn't work...

    I really appreciate your help

    I hope you understand my message (English is my second language)

    This is the source code:

    Code:
    ora_parse($cur,"select * from quotation_tb where qot_company='$company' and qot_quot=$n_qot");
    if (ora_exec($cur))
    {
      if (ora_fetch($cur))
      {
        $customer = ora_getcolumn($cur,2);
        setcookie("list","",time()-3600);
        setcookie("list_currency","",time()-3600);
        /*setcookie("list_currency",","",time()-3600); This was the first text i wrote, it was wrong because the expire time is the 3rd value*/
        setcookie("list",ora_getcolumn($cur,14));
        setcookie("list_currency",ora_getcolumn($cur,15));
     }
    }
    Thanks for your support...
    Last edited by Sheripchi; Apr 21, 2006 at 10:31. Reason: Writing Error

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) Edit your post and put code tags around your code.

    2)
    I try to expire them with "time()-3600" before update them, but it doesn't work...
    How do you know?

    3)
    Code:
    setcookie("list_currency",","",time()-3600);
    How many arguments does setcookie() take, and which one is the expiration time?

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    About the question:

    "How do you know???"

    I don't understand what are you trying to ask me...

    What I need to do is update the cookie value, I suppose if there's a cookie created previously and I use setcookie, I suppose PHP update the value of the cookie with the new I put in the setcookie command...

    Thanks for you help...

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    About the question:

    "How do you know???"

    I don't understand what are you trying to ask me...
    I try to expire them with "time()-3600" before update them, but it doesn't work...
    Prove to me that it doesn't work. Post some code that proves the cookie didn't expire.

  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks...

    Thanks for your help with this...

    I only need to update a cookie...

    What do you do to update a cookie???

    I use setcookie, it works with almost all that cookies.
    ---- I don't know why this works normally and with this two don't ----

    I going to explain what I'm doing...

    Happen that I've two cookies with: the name of a price list for some items and the currency of that price list... OK...

    Those cookies get their values when the user access my program. Well, there's an option where the user can choose an quotation created previously, when the user chose the quotation, the program calls a php file where I check if that quotation exists and take some information of it. I take the original price list and currency that user used when created the quotation and try to update the "list" and "list_currency" cookies.

    I going to attach a file with the code... *** The file is design for a spanish software ***
    Attached Files Attached Files

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For now, your zip file is irrelevant. This is troubleshooting 101. You need to post some example code(which should be in some files with no more than about 5 lines of code per page) which demonstrates that when you set a cookie, and then reset the cookie, the value doesn't change.

  7. #7
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/setcookie

    Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client.
    In PHP 3, multiple calls to setcookie() in the same script will be performed in reverse order. If you are trying to delete one cookie before inserting another you should put the insert before the delete. As of PHP 4, multiple calls to setcookie() are performed in the order called.
    I don't know if either apply as I can't download your zip while at work.

  8. #8
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    21
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Post the implementation of your setcookie function.


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
  •