views:

117

answers:

2

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 XMLHttpRequests. 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.

A: 

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.

matpol
A: 

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

fms