concept cookie in category gwt

This is an excerpt from Manning's book GWT in Action.
Using RequestBuilder (chapter 12) you can set a custom header in the request (using the setHeader method) to contain the value of a cookie originally set by the server. On the server side you can compare the value of the cookie sent in the request to the copy of the cookie in the header—if they don’t match, then you’re being attacked.
Table 13.2. GWT configuration properties involved in determining the locale
Name
Default value
Description
locale.queryparam locale The query parameter name where the locale could be found in the URL. Its value defaults to locale for backward compatibility with older code, but if you wish to use a different value in your application, you’d set it using this configuration property. locale.cookie <blank> New for GWT 2.2. You can check for the locale in a cookie, and this configuration property is used to identify the name of that cookie. By default it’s blank and so is not effective in the determination of the locale. locale.useragent N Also new for GWT 2.2. You can use the browser’s headers to determine the locale. This functionality may or may not be useful. If you’re sure that the locale of all users can be determined from headers, then this is great—but think of the case when you go abroad and try to use your application. Do you want your locale or that of where the browser was built shown first? By default this is set to N so that it isn’t used. locale.usemeta Y Indicates if GWT should look in the meta tags of the HTML page for a meta tag showing the locale. By default it’s turned on for backward compatibility. On top of the four configuration properties given in table 13.2, there’s an additional configuration property: locale.searchorder. The value in this configuration property is an ordered list of which approach to use and in what order. Valid values are query-param, cookie, meta, and useragent, and by default this is the order they’re used in.
By default, GWT has defined the waterfall shown in figure 13.13. Let’s say that you want to change this, so that GWT searches for the query parameter called lang, then a cookie also called lang, and finally at the browser’s user agent but not the meta tag. You’d write the following in your application’s module file:
Locale can be found from a cookie, if it exists. If you add the following to your GWT module file
<set-configuration-property name='locale.cookie' value='lang'/>then GWT bootstrapping will look for the cookie named lang (assuming it hasn’t found the locale using a previous method).
Using a cookie is less transparent to the user, and some users block cookies for security reasons. But it does have the advantage of not cluttering up your web address (with the disadvantage that sharing the URL won’t keep the locale choice).
It’s easy to set a cookie in GWT; you use the setCookie method from the com.google.gwt.user.client.Cookies package. For example, to set the cookie with name lang to have value sv you write
Cookies.setCookie("lang", "sv");You’ll need to refresh the page to see any changes as a result of setting a cookie. You might also want to use the setCookie methods that add an expiration date or domain for security reasons rather than the simple version we’ve just used.