Last updated 2004-06-28 by Roedy
Green ©1996-2004 Canadian Mind Products
Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
You are here : home : Java Glossary : C words : cookie.
The browser records the cookies with the site they came from, an expiry date, the cookie name and its value. They are exchanged quietly between the browser and the server without displaying them on the screen. Every time your browser makes a request of a domain/path for which it has a cookie, it automatically piggybacks the cookie in the HTTP Cookie: request header line. The host does not have to request it.
Applets too can play with cookies, but only with the ones put there by the server from which they were loaded, or that were put there by Applets from that server. Applets can both read and write the cookies stored in the browser, just as the server can.
Tom Hall provided the following code snippet to allow an Applet to write a new cookie or to read the cookies it is permitted to see. To delete a cookie, rewrite it with an expiry date in the past. Surprisingly, even though this code makes use of the Netscape JSObject, it works fine in Internet Explorer as well - no need to include the JSObject class files as they are packaged with IE's Virtual Machine. For it to work, your APPLET tag must include the MAYSCRIPT option.
You will also have to put the file \program files\netscape\communicator\program\java\classes\java40.jar on the classpath when you are compiling. The IE browser will deal with finding the classes at run time. Unfortunately, the only browser I found that supports this is Internet Explorer 5.5/6.0.26. Not even Netscape 4.79 works!
![]() | Core Web Programming, Second Edition | ||||||
| 0-13-089793-0 | |||||||
| Marty Hall and Gary Cornell | |||||||
| 1250 pages. This is a great doorstop of a book. It has a few chapters on client-server programming in Java, and a section of that is on CGI. I have looked at hundreds of Java books and found nothing that deals in depth with client side Java talking to CGI, except Marty's book. It is really very simple and he does an excellent job of explaining it. Marty has posted all the source code examples from the book for anyone to use. These contain updates and errata fixes you don't get on the CD-ROM that comes with the book. | |||||||
| |||||||
I have only been able to get cookies to work in IE 5.5, not Netscape or Opera. Perhaps it would be best to try with JavaScript read/write cookie functions.
home |
Canadian Mind Products | |||
| mindprod.com IP:[24.87.56.253] | ||||
| Your IP:[80.134.30.163] | ||||
| You are visitor number 2757. | ||||
| Please send errors, omissions and suggestions | ||||
| to improve this page to Roedy Green. | ||||
| You can get a fresh copy of this page from: | or possibly from your local J: drive mirror: | |||
| http://mindprod.com/jgloss/cookie.html | J:\mindprod\jgloss\cookie.html | |||