troubleshooting Question

Interaction between Applet, Cookie e doesn't works in Firefox

Avatar of calypsoworld
calypsoworldFlag for Portugal asked on
6 Comments1 Solution696 ViewsLast Modified:

I have an Applet that gets the username through a cookie set by page (the page that contains the applet).

Java Code to get the cookie

    private void getUserNameFromCookie() {
        try {
            // get the cookies that are applicable for this applet's parent web page
            URL docBaseUrl = this.getDocumentBase();

            CookieHandler cookieHandler = CookieHandler.getDefault();
            java.util.Map<String, List<String>> headers =
                    new HashMap<String, List<String>>());

            if (headers.isEmpty()) {
                System.out.println("No cookies found!");
            } else {
        } catch (Exception e) {
            System.out.println("Unable to get cookie using CookieHandler");

    private void getUserNameFromHeader(java.util.Map<String, List<String>> headers) {

        for (String key : headers.keySet()) {
            for (String value : headers.get(key)) {
                if (key.equals("Cookie") && value.startsWith("userName")) {
                    userName = value.split("=")[1];
    } C# code to create the cookie (on Page_Load)

            HttpCookie appCookie = new HttpCookie("userName");
            appCookie.Value = Session["user"].ToString();

            appCookie.Expires = DateTime.Now.AddDays(1);
            appCookie.HttpOnly = false;

In IE everything works nice, but in Firefox the operations that requires the username from cookie are not launched.

Any idea on how to resolve this?

Thanks in advance!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros