Results 1 to 2 of 2

Thread: Cookie Issue

  1. #1
    Join Date
    Jun 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cookie Issue

    Hi

    I have JS cookie code that I have been using over the past little while and
    it works.

    But I'm having a problem reading cookies back on the website I'm
    working on and I think it's because I'm using a window.location.href
    in my code.

    What I am trying to do is write 4 variables to cookies and then I
    do a window.location.href to a new page. When I try to display the
    cookies on this page using my getCookie function, I'm getting nothing.

    Here is my code for the 1st web page....

    function CheckProductForm(inp, form)
    {
    var bIsValid = true;

    if (inp.value >= 5)
    {
    var sName = (eval ("document." + form + ".item_name" + ".value"));
    var sNumber = (eval ("document." + form + ".item_number" + ".value"));
    var sQuantity = (eval ("document." + form + ".quantity" + ".value"));
    var sCostPerCourse = (eval ("document." + form + ".amount" + ".value"));

    /* ERASE PRE-EXISTING COOKIES */
    eraseCookie ("CourseName");
    eraseCookie ("CourseNumber");
    eraseCookie ("CourseQuantity");
    eraseCookie ("CourseCost");

    /* WRITE THESE VALUES TO A COOKE */
    setCookie ("CourseName", sName, 3);
    setCookie ("CourseNumber", sNumber, 3);
    setCookie ("CourseQuantity", sQuantity, 3);
    setCookie ("CourseCost", sCostPerCourse, 3);

    /* FORWARD TO NEW CONTACT PAGE */
    inp.value = "";
    var sTemp = "To purchase 5 or more On-line programs, please complete the following information and an ETL representative will contact you.";

    bIsValid = false;

    window.location.href = "http://www.website.com/contact_store.html";
    return bIsValid;
    }
    }

    On the web page I'm forwading it to.....


    function GetStoreInfo()
    {
    var sName = getCookie("CourseName");
    alert (sName);

    var sNumber = getCookie("CourseNumber");

    var sQuantity = getCookie("CourseQuantity");
    var sCost = getCookie("CourseCost");

    }

    I'm getting a blank alert box.

    Any help would be appreciated.

    Thanks.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •