On Jun 24, 2:04 pm, furby <[email protected]> wrote:

> Is it possible to set a cookie in one gadget and access it from
> another?

Congratulations! You have just hit upon your long-sought technique for
inter-gadget communication. :^D

When I first read your question, my initial reaction was "Of course
not!" But then I stopped and thought for a second, and then I built
the following gadget:
http://gad.getpla.net/test/mmm_cookies.xml

Add 2 copies of it to your iGoogle page, and marvel as the text you
save from one can be loaded into the other.

> They would both be running in containers on the same page

They don't have to be, actually. They can be on different iGoogle
tabs, for example. There's some restriction as to what containers
different instances can be in, but it actually covers quite a lot of
scope - I just loaded a cookie into GMaps that  I'd saved in iGoogle
seconds before.

The proof-of-concept I whipped up above only uses session cookies, but
that might be sufficient for your purposes, or I'm sure it could be
adapted to use persistent ones.

Now, the bad news...

Being cookie-based, it obviously won't span clients, or browsers, or
anything like that. This isn't data in the cloud, as many users will
expect from iGoogle.

Also, there's absolutely no security here. The cookies are written to
the gmodules.com domain (that's the secret ingredient), so ANYTHING
served from a sub of that domain can read them - other gadgets in
particular. They're also easily visible to the user, if they know
where to look.

Finally, if you want to use it in a different container, you may need
to find the correct domain to save the cookies to. Lots of containers
(like Gmail) don't serve their gadgets from gmodules.com anymore. It
wouldn't be hard to adapt the gadget to find the right domain itself,
but my example doesn't.

But in summary, from your earlier comments I'll bet you can live with
these restrictions. It'd be quite reasonable to poll the cookie for
changes; there's not even a server round-trip involved, so you could
do it several times a second without impacting performance.

Good idea!

String
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to