Working With Cookies
Trail: Custom Networking

Lesson: 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,, and the following supporting classes and interfaces:,,, and

HTTP State Management With Cookies

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

CookieHandler Callback Mechanism

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

Default CookieManager

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

Custom CookieManager

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

Previous page: Previous Lesson
Next page: HTTP State Management With Cookies