encryptor
encryptor

Reputation: 373

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

Upvotes: 1

Views: 4301

Answers (2)

flpmor
flpmor

Reputation: 861

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

Upvotes: 4

matpol
matpol

Reputation: 3074

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.

Upvotes: 1

Related Questions