In this article we’ll consider how to restore the previous session with open tabs in Mozilla Firefox. The problem of loosing all tabs as a result of Mozilla Firefox crash (due to different reasons: from power outages to running out of available memory and system hang) occurs quite often.
The mechanism of automatic Session Restore appeared in the second version of the browser already. Firefox saves all open windows and tabs, including urls of pages, the size and position of a window/tab and information entered into the text fields, into a special file (sessionstore.js). When the session has been completed incorrectly, Firefox tries to automatically restore the previous session based on the data in this file with all windows and tabs that had been opened before the browser failed. If the browser fails in the second time, the window with the following message appears after you start Firefox for the next time:
Well, this is embarrassing.
Firefox is having trouble recovering your windows and tabs. This is usually caused by a recently opened web page.
You can try:
- Removing one or more tabs that you think may be causing the problem
- Starting an entirely new browsing session
Firefox can restore all windows and tabs open at the last exit or unexpected failure of Firefox. If you check the tabs opened earlier that have to be restored and click “Restore” button, Firefox opens these web-pages.
If the Session Restore window doesn’t appear automatically, you can try to call it by clicking History -> Restore Previous Session.
If Restore Previous Session menu is not active (as in the snapshot), something has gone wrong and you’ll have to use advanced means to restore the tabs.
Firstly, let’s talk about the backup mechanism of open tabs and windows in Firefox. Firefox saves the information about the current session in sessionstore.js, which is located in the user profile folder (C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\xxx.default – in Windows 7 and 8, or c:\Documents and Settings\username\Application Data\Mozilla\Firefox\xxx.default in XP). If you track how its size is changed in process of working in Firefox, you can notice that when opening a new tab/window its size grows, and when closing a tab/window, it reduces.
After its failure, Firefox automatically tries to load the information about open tabs and windows from sessionstore.js. If this file is damaged, unavailable, has wrong format or browser doesn’t see it on some reason, Firefox starts a new clean session, and Restore Previous Session menu becomes inactive. However, there is no reason to give up — there are some other ways to restore the list of previously opened tabs.
The matter is that sessionstore.bak that contains information about the previous Firefox session is stored in the same profile directory. This file is a copy of sessionstore.js, which is automatically created if Firefox has failed in the previous time.
Close Firefox and rename sessionstore.bak into sessionstore.js (with replacement), then try to run Firefox again. Look, if the previous session restore has been successful.
If this means hasn’t helped, you can try to get a URL list from sessionstore.js files. The file format is quite specific. You can analyze file contents manually and find all open pages that are contained in the constructions starting from “url”:”http, but it’s quite hard and time consuming.
Let’s try to automate extraction of urls from this file:
- First of all, you need to install Firefox extension for developers Firebug (Firefox -> Add-ons – > Get Add-ons -> Firebug – > Install).
- Then find the previously copied file sessionstore.js and rename it into sessionstore.txt.
- Open this file in the browser (Firefox->New tab ->Open file, specify the path to the txt file).
- Run Firebug console (Firefox->Web Development->Firebug-> Open Firebug)
- In the bottom of the window there is a console prompt (it is marked with the red rectangle on the screenshot). Copy the next js-code into it:
javascript:(function(){var D=document,H,i=j=0,P=D.getElementsByTagName('PRE'),t='',R=/[^:]\{"entries":\[\{("url":"([^"]*)")\,("title":"([^"]*)"){0,1}/g,T,U;for(j=0;E=P[j];j++){H=E.innerHTML;while(R.exec(H)){U=RegExp.$2;T=RegExp.$4;if(T.length==0){T=U;}t+='<b>['+(++i)+']</b> <a href='+U+'>'+T+' ('+U+')<\/a><br>';}}with(window.open().document){write(t);close()}})();
And press Enter. - After that a new tab appears that contains all the links the script has been able to extract from the session restore file.
- Open the links you need.
3 comments
How many previous sessions are stored? Can I go back to older than previous sessions?
I closed Firefox with many tabs, did a virus scan, and after completing it, the program popped up a Firefox window with an ad. Now that’s the previous session! In trying to remedy that, the session I want is now several sessions back.
Thanks,
Hi,
My story was this: in “about:preferences” checked “Show my windows and tabs from last time”. 90 tabs is opening every time I open Mozilla. Last time I close my browser not seeing an advertising window opened. In time moment I felt the ceiling falling on my head… Tryied many times to restore and NOTHING! The solution is below:
My Restore Previous Session remains grey (inactive)… I have to mention I already replaced sessionstore.js with my previous back-up. A genius idea was (in a totally desperate case) to click on “Restore All Windows” (History->Recently Closed Windows->Restore All Windows).
Don’t forget to have “Show my windows and tabs from last active” option active when close your browser after that.
Let me just say that I love you for this comment. I had a ton of important tabs open on Firefox and another window with one tab. I closed the first window with multiple tabs, hoping to restore the session later, while keeping the other window (with one tab) open. Then I opened a new Firefox window and the Restore Previous Session was greyed out. Thankfully I found your comment which said one should go to History > Recently Closed Windows > Restore All Windows . Through that I was able to restore my previous session in the other window.
I cannot tell you how grateful I am to you for this! Thank you forever <3