问题
I have an issue that should be fixed on the server side, but a quick workaround on the client side would be acceptable.
I need to make a JS call after the page is loaded and the http-only secure cookie is already set. I'm using window.onload event to call window.location.replace(), but even though the page is loaded with the SET-COOKIE HTTP response header, the new request doesn't send the cookie.
How to make sure the Cookie is set before a new request is made?
回答1:
A workaround that works for Chrome, FF and IE8+ is to use a setTimeout() inside the window.onload event handler. I'm looking for a better solution and an explanation, though...
Thanks,
来源:https://stackoverflow.com/questions/24091210/how-to-make-sure-the-cookie-is-set-before-a-new-request-is-made