import java.Applet.Applet;

import netscape.javascript.JSObject;

/**
 * Official way to set cookies in an Applet in a browser. Only works in IE.
 */
public class cookies extends Applet
   {
   public void init ()
      {
      try
         {
         JSObject window = JSObject.getWindow(this );
         JSObject document = (JSObject)window.getMember( "document" );

         // write one more new cookie
         document.setMember( "cookie", "drink=root beer; expires=Fri, 31-Jan-2008 00:00:01 GMT;" );

         // get all the unexpired cookies
         String mycookies = (String) document.getMember( "cookie" );
         }
      catch ( Exception e )
         {
         }
      }
   }

/**
 * code to set cookies in other browsers. You must set one field at a time.
 */
public class cookies extends Applet
   {
   public void init ()
      {
      try
         {
         JSObject window = JSObject.getWindow(this );
         JSObject document = (JSObject)window.getMember( "document" );

         // write one more new cookie
         document.setMember( "cookie", "drink=root beer;" );
         document.setMember( "cookie", "expires=Fri, 31-Jan-2008 00:00:01 GMT;" );

         // get all the unexpired cookies
         String mycookies = (String) document.getMember( "cookie" );
         }
      catch ( Exception e )
         {
         }
      }
   }