A.8. Handling Cookies

Typical Uses of Cookies

  • Identifying a user during an e-commerce session

  • Avoiding username and password

  • Customizing a site

  • Focusing advertising

Problems with Cookies

  • It's a privacy problem, not a security problem.

  • Privacy problems include: servers can remember what you did in previous sessions; if you give out personal information, servers can link that information to your previous actions; servers can share cookie information through use of a cooperating third party like doubleclick.net (by each loading image off the third-party site); poorly designed sites could store sensitive information like credit card numbers directly in the cookie.

General Usage

  • Sending cookie to browser (standard approach):

     Cookie c = new Cookie("name", ...

Get Core Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.