How to restore Firefox sessions if Session Restore is not working correctly
Session Restore is a useful feature in Firefox that remembers certain information about your previous browsing session so that you can continue work right where you left off the last time.
The feature saves open windows and tabs, the size of each window and its position on the screen, as well as all text that you have entered in forms in any of the open tabs.
When I look back, I can think of a couple of occasions where Session Restore failed to restore the previous session on my system. It was my fault sometimes, for instance when I disabled the "remember my browsing and download history" option in the browser's preferences. At other times it was the browser's fault.
I was in shock whenever that happened as I thought that I lost all of the open tabs in the browser. While I only have about 50 or so open at all times, I have usually not bookmarked the tabs which means that most of the information are lost for good.
Where the Session Restore files are stored
- Window XP and earlier: C:\Documents and Settings\<Windows login/user name>\Application Data\Mozilla\Firefox\Profiles\<profile folder>
- Windows Vista and later: C:\Users\<Windows login/user name>\AppData\Roaming\Mozilla\Firefox\Profiles\<profile folder>.
- Linux: ~/.mozilla/firefox/<profile folder>
- Mac OS X: ~/Library/Mozilla/Firefox/Profiles/<profile folder>
- Mac OS X: ~/Library/Application Support/Firefox/Profiles/<profile folder>
The browser stores the session file sessionstore.jsonlz4 in the user profile directory. This is the active session file that Firefox loads when you start the browser.
Firefox stores recovery files in the sessionstore-backups folder of the profile folder:
- previous.jsonlz4 -- the last session backup that Firefox created.This is the file that you want to try to restore first (unless it has a very low size).
- upgrade.jsonlz4-"number" -- previous session backups, usually created during upgrades of the browser. Use these if previous.jsonlz4 fails to do the trick.
Firefox 56 and newer instructions
Mozilla changed the format of session backup files and that means that the previous way of restoring sessions needed updating.
- Close the Firefox browser. Make sure no instance of the browser is running.
- Open the profile folder and rename the current session file sessionstore.jsonlz4 to sessionstore-backup.jsonlz4.
- Open the sessionstore-backups folder of the profile.
- Rename recovery.jsonlz4 to recovery-backup.jsonlz4.
- Rename recovery.backlz4 to recovery-backup.backlz4.
- Copy the session restore backup that you want to restore, e.g. previous.jsonlz4.
- Go back to the root directory of the Firefox profile.
- Paste the copied file to the root folder.
- Rename it to sessionstore.jsonlz4.
- Restart the Firefox browser.
- Firefox might pick up the session automatically. If it does not, press the Alt-key on your keyboard and select History > Restore Previous Session.
The old information
May still be useful for old versions of Firefox, and Firefox-based browsers such as Pale Moon.
Firefox 33 changes
Mozilla has improved the Session Restore feature in Firefox 33. The core changes are as following:
While sessionstore.js is still stored in the main Firefox profile folder, all other files are now stored in sessionstore-backups instead. Note that sessionstore.js is only shown when Firefox is not open.
The primary backup file is recovery.js now, the secondary backup file recovery.bak. You can use the other session backups listed there as well to restore sessions.
You can still use these files and replace the sessionstore.js file in the main directory.
Additionally, you find previous.js and upgrade.js there as well. These files contain session information from the last shutdown or upgrade. They too can be used to replace the main sessionstore.js file should it be corrupt.
The new backup process
- Firefox writes contents of Session Restore to sessionstore-backups/recovery.js whenever it is required.
- Before that happens, it will move the previous recovery.js file if tests return it as good to recovery.bak in the same folder.
- Usually, recovery.js and recovery.bak contain both the state of the browser 15 seconds apart from each other.
- When Firefox is shut down, a new sessionstore.js file is written to the main profile folder.
- During start up, if sessionstore.js is valid, it is moved to previous.js in the sessionstore-backups directory.
- On the first start up after an upgrade, Firefox copies the sessionstore.js file to upgrade.js-[build id].
The restore files
As mentioned before, Firefox saves several new session restore files to the user profile directory once the new feature lands in the browser (Nightly users already have it as it lands in Firefox 33 if things go as planned).
- sessionstore.js - The state of the browser during the last shut down.
- sessionstore-backups/recovery.js - Contains the state of Firefox 15 seconds before shutdown or crash.
- sessionstore-backups/recovery.bak - Contains the state of Firefox 30 seconds before shutdown or crash.
- sessionstore-backups/previous.js - Session Restore data before the second to last shut down.
- sessionstore-backups/upgrade.js-[build id] - Session Restore data after the latest upgrade.
The process in Firefox 33 to Firefox 55
Here is the order in which Firefox attempts to restore the previous session on start.
- If sessionstore.js is valid, it will be used.
- Recovery.js will be used if present and valid.
- Recovery.bak will be tried next.
- Previous.js is then used to restore the session.
- And finally, upgrade.js will be tried as well.
So what is different in comparison to the old session restore? First of all, you may notice that additional files are saved by the browser which increases the chance that one of the session restore files is not corrupt and working.
In addition, both the previous.js and upgrade.js files are not replaced as often as the two main session restore files. This provides another option of recovering a session if both primary session files are no longer working, or if you have started the browser several times after you noticed that the session was not restored properly.
The new system offers additional means to recover sessions manually as well. Previously you had to rely on the backup file only to restore a session if the main sessionrestore file was corrupt. Now, you can also try recovery.js or upgrade.js, both of which are usually created farther back in time making it more likely that they are not corrupt as well.
What many Firefox users do not know is that Firefox saves two files with Session Restore information to the user profile:
- sessionstore.js contains information about the current session. If you monitor the file you will notice that its size increases and decreases during a browsing session.
- sessionstore.bak which contains session information from the previous session.
Restoring the Firefox session
Once you have backed up both session files, you can start to investigate the issue and try to restore the previous session.
First thing you may want to do is compare the size of the sessionstore.js and sessionstore.bak file. If either file has a size of 0, it is empty and not usable anymore.
With Firefox closed down completely, open one then the other file in a text editor of choice. It should display session information in text form. If you see corrupt text or no information at all, it is clear that the Session Restore file is corrupt and not usable anymore.
You can still try and extract web addresses from it if some information are still displayed in it. This may allow you to recover at least some websites that you had open previously.
Before you do so, try deleting the broken sessionstore.js file and rename the sessionstore.bak file to sessionstore.js.
This attempts to restore the browsing session from the backup. Note that it does not include tabs, windows or forms that you have opened in your last session, and that it may include tabs, windows or form data that you have closed in the previous session.
Recovering the session with help of the backup session file should work if the main file has been corrupted. It may not help you directly if a Firefox setting prevents the browser's Session Restore feature from working correctly.
You can however still open the file in a text editor to extract the information manually from it if they are still listed in the main or the backup file.
Tip: You may use the Firefox extension Session Boss to save and restore sessions.Advertisement