views:

250

answers:

1

Hello Everyone,

I created a FireFox extension. This extension has some configuration settings and I'd like to store them in a cookie. To store information in a cookie I used the regular JavaScript property document.cookie

Initially everything seemed to work fine, but then I noticed that the cookie is just a session cookie. Whenever I reload the XUL file, then the cookie (i.e. document.cookie) is empty. The expiration data of the cookie was set 1 year ahead, so that shouldn't be the problem.

To prove whether de JS code is correct, I tested the same JavaScript code embedded within an HTML file. In that case the cookie is stored and remains valid until it's expiration date is reached. I did this test using the same browser (FireFox on WinXP).

Questions:

1) Did anyone face the same (or a similar) problem? 2) Is it possible to read/write cookie via document.cookie within XUL files or is it ONLY possible using the XUL cookie service?

Many, many thanks in advance,

A: 

When I need to store settings, I use the preference manager provided by Firefox (nsIPrefService). There's a great description of how to interact with it at https://developer.mozilla.org/en/Code_snippets/Preferences along with code samples and information about how to integrate it into an extension.

warhammerkid