• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Applet CookieManager not adding cookie to browser

 
Nguyen Dang Luat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application, we use java applet to write cookie on browser and use jquery to read this cookie. I tried do like tutorial but I always don't see the cookie set on my browser.

http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html And here is my code: The first I create a class to handle the cookie



Then I call it in main applet (I use jquery to run this applet):

try {
cookie = new CookieAccessor();
HttpCookie cookiedata = new HttpCookie("UserName", "Jonh");
URL url = new URL(getCodeBase().toString());
cookie.add(url.toURI(), cookiedata);
} catch(Exception e) {
e.printStackTrace();
}

But I've checked the browser cookies and there's no UserName What is missing in this code?

Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic