Ajax and PHP cookies in Firefox

Discussion in 'Javascript' started by GodSurfer, May 4, 2007.

  1. GodSurfer

    GodSurfer Guest

    All,

    I am trying to set a cookie on my page.

    I have a div that contains a form where on the onclick of the button
    calls a javascript function:

    function login(){
    loginAJAX(document.getElementById("userName").value,
    document.getElementById("password").value);

    }

    /*Standard AJAX Code goes here*/

    function loginAJAX(userName, password){
    //alert(userName);
    if (!isWorking && http)
    {
    var pageURL = ""; // The server-side script
    pageURL = "functionLogin.php?userName=" + userName
    +
    "&password=" + password;
    }
    // alert(pageURL);
    http.open("GET", pageURL, true);
    http.onreadystatechange = handleHttpResponse;
    isWorking = true;
    http.send(null);
    alert(http.responseText);

    }

    The functionLogin.php has the following code snippet:

    setcookie("userName", $username,
    time()+3600, "/",
    ".myDomain.com", 0);
    setcookie("id", $row["userId"],
    time()+3600, "/",
    ".myDomain.com",0);

    This all works very well in IE 6.0 but Firefox doesn't set the
    cookies...

    Now when I just call functionLogin.php the cookies get set in both
    browsers... I think it has something to do with the AJAX call but I'm
    not sure... Any ideas?

    BTW -- I'm going to also post this in an AJAX forum as well, but I'm
    just not sure if it is my PHP or the AJAX.

    Thanks for any and all help.

    JV
     
    GodSurfer, May 4, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. minnie
    Replies:
    1
    Views:
    714
    Andrew Thompson
    Dec 13, 2006
  2. archana
    Replies:
    1
    Views:
    511
  3. _Who
    Replies:
    7
    Views:
    2,686
  4. Rajive Narain
    Replies:
    0
    Views:
    1,900
    Rajive Narain
    Sep 18, 2009
  5. duane
    Replies:
    1
    Views:
    86
    Janwillem Borleffs
    Sep 18, 2003
Loading...

Share This Page