Automatic per-tab session isolation with Firefox

This is a guide to make automatic isolation a part of your web browsing.Instead of pulling out my tinfoil hat and going into too much detail on the why, I'll try to keep this as a step-by-step guide with some tips.

Step 1: Firefox

If you're already using Firefox as your main browser, you're good to go.If not, then get Firefox. It's good for the web as is. Seriously.If you're using Firefox and you really don't want to mess with your current set up, you can also go to about:profiles, click on "Create a New Profile", follow the instructions and then click on "Launch profile in new browser". You can easily delete the profile later if you no longer need it.

Bonus tips to make your life better

Get uBlock Origin. It's a lightweight ad blocker and more, "for users by users". Usually just works but some sites do require you to disable it via the red shield icon in your toolbar.Enable dark theme via the hamburger menu (top right) > Customize... > Themes (bottom) > Dark. I heard dark themes are a thing right now.From the customization view you can also change the UI density and remove things from the toolbar, such as empty space and the home button, by dragging them.

Step 2: Temporary Containers

There's a good explanation on what containers are in the description of the official Multi-Account Containers add-on. You can go install it, although it will only add a single button for managing permanent containers. The core functionality is already built into Firefox even without the add-on. You can also read the knowledge base article on Containers for a more thorough explanation.Once you've got an idea of what containers are in Firefox, go get the Temporary Containers add-on, which enables automating the creation and removal of containers.Temporary containers are containers that act a bit like the regular private mode in browsers, with the exception that history is retained and you can have as many of them open simultaneously as you want.Multiple tabs can belong to the same temporary container, but when you close the last tab of a temporary container, the container will be deleted, with a configurable delay to allow for re-opening the tab.The way the Temporary Containers add-on works by default is that you can manually open a temporary container tab either with the default keybinding (Alt + C) or with the Temporary Container button, which is the alarm clock icon with a plus sign in it.If you don't open one, everything works just as normal.

Step 3: Automation

The manual way takes conscious effort though, and the point here is to automate container tabs so that your sessions and other cookies are isolated by default. Temporary Containers has an option for exactly that.Go to Add-ons from the hamburger menu, or about:addons, and select Extensions if not already selected. From there, open the Options for Temporary Containers.The first option is "Automatic Mode", which on hover will show a description of it's operation. Enable that. The rest of the options on this page are a matter of taste. Feel free to fiddle with them.Next, go to Isolation > Global > Mouse Clicks on Links... and set Middle Mouse and Ctrl/Cmd+Left Mouse to "Always". Leave Left Mouse on "Never". In practice this means that whenever you consciously open a new tab, even if it's via a link, it will be in a blank session.Note that redirect links with tracking codes (Google, Facebook, Twitter) can still follow you into the new session, but let's not go into that here.Optionally you can also enable local statistics on the last options page, if you're into that.

Step 4: Permanent containers

Using temporary containers means you're never signed in to any website by default, so you'll most likely want to add at least one permanent container.As said earlier, containers are a built-in feature of Firefox now, so you can find more information on them from the browser's documentation, but I'll show you the basics.To manage containers, I recommend you hold down the new tab button, which is the plus sign after the last tab, and select "Manage Containers".By default, Firefox will give you a few example containers, but you can remove these and add your own, or edit them to suit your use cases.You can give permanent containers an icon and a color to distinguish them from each other and from temporary container tabs.I like to have a separate container for each web service I use a lot, but the default containers may very well work for you.If you use one service, for example Google, to sign in to other services, then you may want to keep some or all of those services within a single container, depending on the trade-offs you're willing to make.You can also have specific websites always open in a permanent container. To do this, you need to have the official Multi-Account Containers add-on from step 2 installed. Navigate to the website using the permanent container of your choice and click on the button added by Multi-Account Containers, then select "Always open in <container name>".

Step 5: Habits

If you've done the previous steps, then at this point your muscle memory and the path of least resistance will always lead to a blank, isolated session. You'll have to take conscious effort to break out of this isolation.You may develop your own habits, but these are some habits I've noticed after using this set up for almost a year now.

  • If you know you want to be signed in on your next navigation, hold down the new tab button and select a container in which you're already signed in to the service you want.
  • If you realize you navigated to a page that you wanted to navigate to as a signed in user instead of an anonymous user, you can right click the tab and select "Reopen in Container".
  • If you want to open a link in a specific container, right click it and select "Open Link in New Container Tab".
  • You can also do those with the left mouse button, if you already have one tab open that belongs to the container you want:To reopen the current page, start dragging from the left of the address bar where there's a circled "i" and hover over your target container tab until it becomes active, then drop in between tabs next to it.To open a link, start dragging the link and drop it the same way. Dropping between tabs will always cause the new tab to open in the same container as the currently active tab.
  • If you want to open a new tab in your current container, you can right click the tab and select "Duplicate Tab". You can also do this by holding Ctrl (Alt on OSX) and dragging the tab.
  • If all else fails, you can open a new tab in the container you want, and copy the web address you want to navigate to into that tab.
  • Get into the mindset that opening a link in the same tab will open the link in the same session, while opening the link in a new tab will open it in a new clean session. Same goes for typing a new address on the address bar.

For web developers, it's often required to test a website as multiple different users as well as not logged in. This is now as easy as opening a couple of tabs and logging in with respective test users.
One thing you'll also quickly notice, especially if you live in the EU, is that the web sucks for first-time visitors, which you now are every time you open a new tab.The best solution is to make the web not suck. You would do a favor for everyone.If you can't do that, then as the next best option I'd suggest you take a look at the Behind The Overlay Revival add-on. It will hide nearly any overlay with a hotkey.If you visit a site often and get tired of hitting the hotkey, then assuming you followed my tips in the first step, you can also right click on what you want to hide and select "Block element". This is a feature of uBlock Origin and will hide the element more permanently. For documentation see the uBlock Wiki.As a disclaimer I'll have to say that I have no idea if hiding in-page popups is a good idea in a legal context, but I'll leave that research and decision to you.If none of these methods work, then I suggest you never visit that website again. Actually you may consider that as the first solution to try.
If you find this set up not suitable for you after all, then I hope you at least learned something about containers along the way.In that case I recommend you trace back your steps one at a time, and first reset the advanced isolation settings. If that's not enough, then turn off automatic mode on Temporary Containers and try using them manually.But if, instead, you start feeling like this should be the way browsers work by default, then you're doing it right!Keep it up.