Firefox extension: how to read a cookie name and value on the current page
My extension works on an application, which requires user login. Once the user has logged in, I need to read the cookies and use them in my XMLHttpReque开发者_如何学Pythonsts. So initially I need to check if the cookie is set, if not, I direct the user to the login page. Once logged in, I need to read the cookies and send it as part of my further requests.
How do I read cookies from a XMLHttpRequest or otherwise (if we don't even know the name of the cookie)
There is to function as getRequestHeader.. but what I need is something like that.
The extension can access the Firefox cookies through the CookieManager XPCOM service. You can use it to read cookies, set cookies, etc. More information and code snippets here:
https://developer.mozilla.org/en/Code_snippets/Cookies
You can use the Web Developer toolbar in Firefox to read cookies. A cookie is a cookie no matter what sets it so it should show up the event it is set with an Ajax request.
精彩评论