Home > Uncategorized > Cookies in Firefox and Internet Explorer

Cookies in Firefox and Internet Explorer

Mmm…cookies…

Firefox and IE handle them differently. Go figure…

Firefox always shares cookies – across tabs and across windows. No matter how your windows or tabs come into existence, cookies are always shared in Firefox.

IE 7 sometimes shares cookies. It always shares cookies in new tabs. It always shares cookies with the new window if you choose File -> New Window from the menu (or use Ctrl+N). However, if you have an IE window open and you use the Start menu or double-click a desktop icon to open another instance of IE, it will not share cookies.

Seems really strange to me, as clicking File -> New Window appears to do the same thing as double-clicking the IE icon on my desktop. Both show up in the taskbar at the bottom of the screen. Both show up in the Task Manager under the Applications tab. But further investigation shows that only one shows up in the Processes tab of the Task Manager.

IE 7 spawns a new process when you open it from the Start menu or the desktop. However, it uses the same process if you open a new window from an existing IE process. This explains why cookies are shared when you use File -> New Window or Ctrl+N.

I ran into problems with this while working on a web application using Servlets & JSP. (If you’re looking for a great reference, check out Head First Servlets & JSP). Once I realized that a session means something different in IE than it does in Firefox, it all made sense, but I spent a lot of time learning this the hard way.

Can’t all browsers act the same?

  1. Marc Peabody
    May 19, 2008 at 12:12 pm | #1

    This may only be true for session cookies in IE. I think if you set an expiration date on your Cookies, they will be shared.

    If FireFox shares all cookies, including a JSESSIONID, doesn’t that mean that you can’t mimic (to, say, test a stale data / race condition) two separate sessions running at the same time… at least without needing 2 computers to do so? That doesn’t seem terribly desirable either.

  2. May 21, 2008 at 8:29 pm | #2

    Marc – in the tests I ran, I found that the JSESSIONID was always the same in Firefox, no matter how I opened new tabs or windows (including running the exe). This held true until I shut down Firefox entirely and restarted it, at which point I received a new JSESSIONID. In IE, the JSESSIONID was different for each running process of IE.

    The JSESSIONID seems to have a one-to-one relationship with the number of processes. Since Firefox never creates more than one process, no matter how you run it, the JSESSIONID is always the same. This is not true for IE – each time you run the executable, IE creates a new process (at least for IE 7), and the JSESSIONID is different.

  3. May 21, 2008 at 8:38 pm | #3

    Here’s another post I found discussing the same topic. It may give you a different perspective and further explanation. One thing he mentioned that I wasn’t aware of was that it seems that JavaScript calls such as window.open use the currently running process, rather than spawning a new one.

  4. Rama
    May 30, 2008 at 6:31 am | #4

    Try using the command “firefox -ProfileManager -no-remote” – and create multiple profiles. That way you will be able to have separate cookies for Firefox

  1. December 31, 2009 at 3:17 pm | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.