Cookies are small pieces of data that are stored in the user's web browser. They can be considered as a small database. Each cookie is defined by a name and value of String
. Cookies have many uses. Perhaps the most common use is user authentication.
In this recipe, we will show how to store information about the last selected tab name. This example is based on the Binding tabs with a hard URL recipe in Chapter 2, Layouts. We will continue on the same implementation. We add two new methods for read and for write cookie. In the original application, if the user entered the URL without the tab name after the hash-tag #
, the first tab was selected. In this new version, the last opened tab will be selected again.
Create application described in the Binding tabs with a hard URL recipe in Chapter 2, Layouts.