I need to access my requestHeaders in my onload function. How can I do that ?
Thanks
I need to access my requestHeaders in my onload function. How can I do that ?
Thanks
If you want to access cookies from within JavaScript you can read them using document.cookie:
allCookies = document.cookie;
allCookies
is a string containing a semicolon-separated list of cookies (i.e.key=value
pairs)
Basically cookies are managed for you in a browser environment. What this means is that any cookies set up by the server should appear on the client (even when using XHR) and should be sent up to the server with every subsequent request, (even when using XHR) - without any intervention.
If you do need to actually access the cookie, As Marcel said, you need to simply use document.cookie
at the correct time after the XHR request has completed.