Cookie that doesn't get sent to server

31 views
Skip to first unread message

Markus

unread,
Jul 16, 2011, 9:38:48 AM7/16/11
to Google Web Toolkit
Hi everyone,

got a quick question / call for some collective brain-storming:

I need to store a small bit of data locally on the client without
creating a dependency on flash, gears, ff3, etc.

The way that seems most natural to me is to use a cookie, but I run
into the following issues with this:
- Simply setting a cookie on the page itself is not a good idea as it
gets sent to the server with every XHR request.
- I added a subdirectory to my site ("localcookies") with a small
script that is loaded into an i-frame and provides a mechanism to set
and read a cookie in that subdirectory. This way, the cookie is sent
only once to the server, when the iframe is loaded.
- Now my hope for the next step was to tell the browser to cache this
script, so that it is not loaded again at all, but that doesn't seem
to work. I actually haven't figured out yet why it doesn't work. It
almost seems like FF doesn't cache pages that have a cookie set...
- Unfortunately, there does not seem to be a way to set or read the
cookie from a script outside the subdirectory either, probably to
prevent cross-site vulnerabilities.

So, what I'm trying to figure out is whether there is any way using
some trick with page caching, URL redirects, subdomains,
subdirectories, etc. to get the browser to not send a cookie to the
server, but still provide access to it from JS.

Or could there be a way to use a URL? Is there, for example, a cross-
browser way to update a bookmark to include the data in a hash tag? Or
could there be a way to use the "save username and password" feature,
or can you access the autocomplete suggestions for a text-box?

I looked at some other posts and most people come to the conclusion
that g-gears or something like this would be the right way to do this,
but I really would not like to create that extra dependency, so let's
not open that discussion here again as there are plenty of other
threads that already talk about this.


Thanks for your help and ideas,

Markus

Jens

unread,
Jul 16, 2011, 12:21:59 PM7/16/11
to google-we...@googlegroups.com
You could use GWT's Storage API (simple key = value storage). I guess it works in all modern browsers. IE6 and IE7 are not supported.



Markus A.

unread,
Jul 17, 2011, 4:41:11 AM7/17/11
to google-we...@googlegroups.com
Hi Jens,

thanks for your reply. I had actually looked into this and was under the impression it requires HTML5, which is not quite that widely available yet. But maybe I misunderstood something. I'll have another look at it.

Greetings,

  Markus

On Sat, Jul 16, 2011 at 6:21 PM, Jens <jens.ne...@gmail.com> wrote:
You could use GWT's Storage API (simple key = value storage). I guess it works in all modern browsers. IE6 and IE7 are not supported.



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/UxdcFt7aadsJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Reply all
Reply to author
Forward
0 new messages