Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Ajax Firefox not sending cookie (Chrome works)
    primarykey
    data
    text
    <p>I'm trying to use Ajax authentication in my app and I seem to have gotten it working, except firefox does not seem to be sending the correct jessionid to the server in the "cookie" request header for subsequent requests whereas chrome does so just fine. Here is the login function:</p> <pre><code>$.ajaxSetup({ xhrFields: { withCredentials : true } }) function sudoLogin(callback){ $.ajax({ url : HOST + "/ProperApp/j_spring_security_check", type : "POST", data : $("#login").serialize(), dataType: 'json', async : false, success: function(result) { if (result.login) { callback(true); } else { callback(false); } } }) } </code></pre> <p>In the response in firefox I can see the cookie being set, and the success callback is called:</p> <pre><code>Set-Cookie JSESSIONID=81235e7ff741e941c1e078afee5c; Path=/ProperApp; HttpOnly </code></pre> <p>However, in subsequent requests, such as this one, the cookie is not being sent:</p> <pre><code>function getUserDeets(callback){ $.ajax({ url : HOST+ "/ProperApp/userData", type : "GET", async : false, dataType : 'json', xhrFields: { withCredentials: true }, success : function(data){ callback(data); } }) } $('#submitLogin').click(function(){ sudoLogin(function(loggedIn){ if(loggedIn){ //window.location = "sudoIndex2.php"; getUserDeets(function(user){ alert(user); }) } else alert("login failure"); }); }); </code></pre> <p>In Chromium, the request contains the cookie header, and the success callback is called correctly:</p> <pre><code>... Connection:keep-alive Cookie:JSESSIONID=8129ef67b59180f9f21383cba850 Host:localhost:8080 Origin:http://localhost:8000 Referer:http://localhost:8000/loginSignup.php ... </code></pre> <p>However in Firefox, the request header does not contain the cookie header, and success is never called:</p> <pre><code>... Connection keep-alive Host localhost:8080 Origin http://localhost:8000 Referer http://localhost:8000/loginSignup.php ... </code></pre> <p>Ive created a ajax filter on the server side, that I think should be allowing this to happen:</p> <pre><code>response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin")); response.setHeader("Access-Control-Max-Age", "360"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Headers", "Authorization"); </code></pre> <p>Any idea why this would work seamlessly in Chrome but not Firefox?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload