views:

27

answers:

1

I am writing a firefox extension that interacts with a JSON server interface. I receive a url to the server which then redirects to the client site that provides the cookie. I need to be able to set this cookie in the users browser without physically loading it in the browser. Is this possible through an AJAX call?

I tried using a hidden iframe, however firefox does not seem to like a php redirect in the iframe. My current solution is to load the site in a second tab that never gains focus and then auto close it when the cookie is set. This is very messy and would prefer something more streamlines.

Any thoughts?

A: 

I have used nsICookieManager2 service successfully although it is not recommended because you need to play well with features like private browsing. Best solution I could come up with was using a hidden <browser> element and using its contentWindow to create XMLHttpRequest objects. You'll certainly want to set allow* properties to false on the docShell beforehand if you go that route.

artificialidiot
I modified this slightly. I used a browser element and set its source to the PHP page which redirected. It is never visible to the user and the cookies are set correctly. Thanks!
Tyler