Tutorial: Working With Cookies

Though you are probably already familiar with cookies, you might not know how to take advantage of them in your Java application. This lesson guides you through the concept of cookies and explains how to set a cookie handler so that your HTTP URL connections will use it.

Java SE provides one main class for this functionality, java.net.CookieHandler, and the following supporting classes and interfaces: java.net.CookieManager, java.net.CookiePolicy, java.net.CookieStore, and java.net.HttpCookie.

This page describes cookies and explains how they are used to provide sessions.

This page explains how a cookie handler is called when you access a web site and how to set a cookie handler.

Java SE provides a default cookie handler implementation that is sufficient in most cases and highly customizable.

Here are some examples of how to customize the cookie policy and write your own cookie store.