How to restore Firefox sessions if Session Restore is not working correctly - gHacks Tech News

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

firefox sessionstore backups

  • 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

sessionstore jsonlz4

Mozilla changed the format of session backup files and that means that the previous way of restoring sessions needed updating.

  1. Close the Firefox browser. Make sure no instance of the browser is running.
  2. Open the profile folder and rename the current session file sessionstore.jsonlz4 to sessionstore-backup.jsonlz4.
  3. Open the sessionstore-backups folder of the profile.
  4. Rename recovery.jsonlz4 to recovery-backup.jsonlz4.
  5. Rename recovery.backlz4 to recovery-backup.backlz4.
  6. Copy the session restore backup that you want to restore, e.g. previous.jsonlz4.
  7. Go back to the root directory of the Firefox profile.
  8. Paste the copied file to the root folder.
  9. Rename it to sessionstore.jsonlz4.
  10. Restart the Firefox browser.
  11. 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

  1. Firefox writes contents of Session Restore to sessionstore-backups/recovery.js whenever it is required.
  2. Before that happens, it will move the previous recovery.js file if tests return it as good to recovery.bak in the same folder.
  3. Usually, recovery.js and recovery.bak contain both the state of the browser 15 seconds apart from each other.
  4. When Firefox is shut down, a new sessionstore.js file is written to the main profile folder.
  5. During start up, if sessionstore.js is valid, it is moved to previous.js in the sessionstore-backups directory.
  6. 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.

  1. If sessionstore.js is valid, it will be used.
  2. Recovery.js will be used if present and valid.
  3. Recovery.bak will be tried next.
  4. Previous.js is then used to restore the session.
  5. 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.

The backup

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.

firefox sessionstore

Tip:You should not re-open Firefox when Session Restore fails to load the previous session as you may end up overwriting the backup file as well. Since it contains information that have not been modified after a session fails to load, you should copy it to a secure location before you continue.

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.

Closing Words

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.

Summary
How to restore Firefox sessions if Session Restore is not working correctly
Article Name
How to restore Firefox sessions if Session Restore is not working correctly
Description
The guide provides you with information on how to restore a session in the Firefox web browser if the built-in session restore feature is not working properly.
Author
Publisher
Ghacks Technology News
Logo

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:

Comments

  1. tPenguinLTG said on June 3, 2013 at 8:16 pm
    Reply

    I just use the restartless add-on Session Manager:
    https://addons.mozilla.org/en-US/firefox/addon/session-manager/

    I have a habit of accidentally pressing Ctrl+Q when I mean to press Ctrl+E or Ctrl+Tab, and I have Firefox set to clear my data after the session. With Session Manager, I could go back to a session from a few days ago if I wanted to.
    Coupled with Dropbox, I use it to sync my sessions across my computers.

    1. Martin Brinkmann said on June 4, 2013 at 2:40 am
      Reply

      It is a great extension, I agree. I have reviewed it here somewhere on the site as well.

  2. Peter said on June 4, 2013 at 3:45 pm
    Reply

    My apologies if the following comment is somewhat off-topic.

    Like tPenguinLTG, I use the Session Manager extension (but in Windows). It’s been a great extension for some time (years?) — far more powerful and useful than Firefox’s built-in Session Restore feature — but in the past couple of weeks I’ve been having a severe problem with Firefox (plus a minor one), and I suspect that either Session Manager, or the way Firefox handles Jetpack (restartless) extensions, is involved.

    The severe problem: Session Manager doesn’t load after Firefox is launched, and the Firefox process hangs at 0% of CPU. Or, Firefox doesn’t load after a session is restored from Session Manager’s initial appearance. Or, Firefox doesn’t load after Session Manager’s initial appearance is *canceled.* Or, Firefox loads after Session Manager’s initial appearance is canceled, but some parts of Firefox’s UI (e.g., Close Tab button) don’t get loaded. The only workaround seems to be to start Firefox in Safe Mode, exit, then restart Firefox normally, cancel Session Manager, wait until Firefox loads all the way and finishes running its initial tasks (automatic extension updates, Firefox Sync, etc.), and only *then* try to restore an old session from within Firefox. It’s a major problem, and another Session Manager user I know is having it, too.

    The minor problem: After you initially load Firefox, some restartless extensions don’t work unless you disable them and then immediately re-enable them (without restarting in between). Any pages you want to use the re-enabled extension on have to be refreshed, as well. So far, I’ve noticed this problem with the cifFix extension and the YouTube Smart Pause extension. Not the end of the world, but a fixworthy bug is probably in there somewhere.

    A less elegant, less automated, but also less error-prone alternative to Session Manager is to use the Bookmark All extension: one click on the Bookmark All button, and your entire session is bookmarked under its own date- and time-stamped bookmarks subfolder.

    I recommend replacing the extension options’ proposed defaults with “[Bookmarked Sessions]” or “[Saved Sessions]” (with no quotes) for the first option (the name of the parent folder), and “Session of ” (with a space at the end and no quotes) — or nothing at all (an empty box) — for the second option (the prefix for the subfolders). [Bookmarked Sessions] and [Saved Sessions] should sort out toward the top of the Bookmarks Menu and are easy to distinguish visually from other bookmark folders.

    The downsides of Bookmark All: you have to remember to click on the Bookmark All button; I don’t think it knows the difference between pinned and unpinned tabs; and I don’t think it knows the difference between tabs in the foreground (displayed) group and tabs in background (undisplayed) groups. The upsides: it doesn’t screw with Firefox or get screwed *by* Firefox, and the sessions it saves will get picked up by whatever bookmark-syncing utility you happen to use.

    1. tPenguinLTG said on June 4, 2013 at 3:54 pm
      Reply

      I don’t get that problem, and it’s probably because I have Master Password+ installed, so Firefox loads (I think) while I’m typing in my password.
      https://addons.mozilla.org/en-US/firefox/addon/master-password/

      Oh, and I found Martin’s review:
      https://www.ghacks.net/2011/12/31/save-and-load-firefox-sessions-with-session-manager/
      I can’t help but think I might have actually found the extension because of that.

      1. tPenguinLTG said on June 4, 2013 at 3:55 pm
        Reply

        Or is it because I’m on the ESR channel?

    2. Martin Brinkmann said on June 4, 2013 at 4:40 pm
      Reply

      Peter, first thing I would try is disable all extensions but Session Manager and see if that resolves the issue. It may be that another extension that is interfering with Session Manager.

      1. Peter said on June 4, 2013 at 6:00 pm
        Reply

        Thanks, Martin!

        I think you may be right. I didn’t run into any problems with Session Manager as the sole enabled extension. I was using a *lot* of extensions (~50). Since running the initial test, I have re-enabled 25 of the ones I consider essential or most useful, and Session Manager has continued to work smoothly over the course of four or five restarts.

        I will have to do more testing (something I thoroughly enjoy, as you might imagine) to be certain, but I now wonder if the “TabGroups Menu” extension might be the culprit. I think both my friend and I had started using that extension not too long before our problems with Session Manager began cropping up. But I’ll have to test to be sure.

        Again, thanks for prodding me to test!

  3. Doug said on June 4, 2013 at 7:48 pm
    Reply

    Martin, I’ve had the same problem with lost Firefox session info, and have a pretty simple improvement, or at least the concept; if Firefox could save the last two backups, then it would at least be harder to overwrite them all while trying to get Firefox working properly. I cannot see how this would be too difficult a programming challenge, and if the Firefox people don’t like the idea, then it might be a good option to add to the Session Manager add-in.

  4. Jojo said on June 5, 2013 at 1:34 am
    Reply

    I’ve run into lost sessions with FF now & then. Sometimes it is my fault because I have a 2nd FF window open behind the main window that I forgot about and it has only one tab open. I close the main window but forgot about the other window, so FF saved the tab from the one tab window. Oh no. It is good to know about the session backup file.

    Anyway, over the years, I learned to take out some insurance and save all open tabs in the main window before I close the window in a bookmark folder called ‘Tab save’.

    1. Martin Brinkmann said on June 5, 2013 at 1:35 am
      Reply

      You can reopen windows from the history menu.

  5. Jerry Stark said on June 21, 2013 at 3:00 am
    Reply

    I have been using restore session for years, and have relied on it to bring back the 25 or so projects that I have going on at any time as well as reminder tabs of things I must do. Well I just had my first problem with resume session.
    Recent Changes: I had updated from Vista to windows 7 a few weeks back and have had a few problem such as:
    – I modified the power options using a custom plan. can not access any of
    the power options since adding the custom plan.
    – I have problems with the ASUS BIOS not able to open asus.io, Asus has
    no idea what is happening. Not sure of the file name right now.
    Back to the present:
    – Firefox restore has worked flawlessly for years.
    – I exited from Firefox and was doing some file work. The system locked up and would not respond and after a good while I did a shut down. I restarted window 7 after a day had passed and it failed to restore my sessions. It did not ask me if I wanted to restore my previous sessions.
    Not knowing the consequences I thought maybe if I restarted the system again it would work, my ignorance.
    I did a search on the sessionstore files and found the following:
    – could not copy the data, so this is a summary:

    1) – 1 files sessionstore C::\users\name\AppData\Roaming\Microsoft\windows\Recent Items 6/20/2013 10:31PM Size11.5kb LNK file

    2) – 1 files C:\users\name\recent 6/20/2013 10:31PM size 11.5kb LNK file

    3) – 1 files sessionstore-1.js C:\users/name\AppData\roaming\microsoft Windows\Recent items 10:31PM 14.6kb LNK file

    4) – 1 files sessionstore-1.js C:\users\name\Recent 6/20/2013 10:31 PM size14.6 kb LNK file

    5) – 1 files sessionstore.js C:\users\name\AppData\Roaming\Microsoft\Windows\Recent Items 6/20/2013 10:28PM size 15.2kb LNK file

    6) – 1 files sessonstore.js C:\users\name\Recent 6/20/2013 10:28PM size 15.2kb LNK file

    7) – 1 files sessionstore.bak C:\users\name\AppData\Roaming\Microsoft\windows\Recent Items 6/20/2013 10:22 PM size 1.34kb

    8) – 1 files sessionstore.bak C:\users\name\Recent 6/20/2013 10:22PM size 1.34kb LNK file

    9) – 1 files sessionstore.js C:\users\name\AppData\Roaming\Mozilla\firefox\profiles\H5evpaz1.default
    6/20/2013 6:44 PM size 3.62 js file

    10) – 1 files sessionstore.bak C:\users\name\AppData\Roaming\Mozilla\Firefox\Profiles\h5evpaz1.default 6/20/2013 6:31PM size 3.54kb bak file

    11) – 1 files sessionstore-1.js C:\users\name\AppData\Roaming\Mozilla\Firefox\Profiles\h5evpaz1.default 4/15/2011 5:56PM size 4.91 Bak file

    – I tried to look at the files with wordpad and notepad, got different results.
    – I could see some text but there was lot that seemed like it might be compressed information?
    – It seemed that these files were tied to the activity during that day rather than a full collection of all the info for all the windows and tabs that should be restored.
    – I backed up the system on May 5, 2013 but I had a lot of new information on various new tabs since that date. I can use the sessionstore files from that backup to get some of the info back but I guess the more recent information is unrecoverable?
    It is late and I am tried, let me know where I stand or what info you would need to access my problem.
    Thanks to who ever responds.

    1. Martin Brinkmann said on June 21, 2013 at 3:15 am
      Reply

      First, backup you profile before you start Firefox again.

      Did you check the recently closed windows listing in the Firefox History?
      Do you have a sessionrestore.bak file in your profile folder?

  6. Jerry Stark said on June 21, 2013 at 1:21 pm
    Reply

    The recently closed tabs and windows were shaded and not available.

    I looked in all the files listed above for the sessionrestore and they varied in content. What I could read appeared to be information records from a single session, particular search paths, and other content appeared to be packed info and unreadable. None appeared to have content for all the files and links that should be restored.
    I am using MS’s computer search to find things as most of the paths use a link containing “users\name\AppData” which do not exist anywhere in directory lists. I’m not sure where that actually points to.

  7. Jimmie said on December 2, 2013 at 4:53 pm
    Reply

    Got this notice that The connection to the server was reset while page was loading. what do this mean ? i was playing the Farmtown game on Fcebook .Now i am not able to get there at all.

  8. Jimmie said on December 2, 2013 at 11:08 pm
    Reply

    What do this mean awaiting moderation, was hopeing for a solution

    1. Someone said on February 10, 2015 at 9:50 am
      Reply

      What do this mean? Get an iphone & stop messing about on a computer. Also maybe use a IE, it’s made for people like you. Honestly, your comments are not only almost illegible nonsense, but completely irrelevant to this post. I am not sure how you even managed to log onto a computer & get online, but then again they have made it too easy these days.

  9. Thankful said on June 1, 2014 at 1:44 am
    Reply

    This worked for me. Thank you Martin Brinkmann!

  10. Anonymous said on September 6, 2014 at 6:26 am
    Reply

    I don’t even HAVE an Appdata folder, so I guess I’m just SOL…Failed restore happens all the time for me (even on proper shutdowns)-it’s a sick joke of a browser~

    1. stache said on September 9, 2014 at 6:22 pm
      Reply

      Try clicking on the window icon or key (the one with 4 boxes) select This PC.
      In the search box enter appdata and it will show you the files with in the directory.

      If you search for sessionstore it should show you the path to where the two firefox recovery files are.

      Hint:
      You cannot have firefox as your default application. Why? because every popup window will be using firefox and unless firefox is already open, it will open it and display the popup. When you close the window it will over-write your sessionstore files.

    2. Someone said on February 10, 2015 at 9:39 am
      Reply

      Obviously you shouldn’t be using a computer. Locating the Appdata folder is one of the easiest tasks you can try to do on a computer. Also, Firefox has a lot more to offer than any other browser out there right now.

  11. bart said on January 1, 2015 at 5:42 pm
    Reply

    This DAMN piece of shit has just deleted all of my tabs and the last session restore file is a month old. They add more and more crap to firefox, but they cant make the basic option work!!!!!

    1. Someone said on February 10, 2015 at 9:54 am
      Reply

      Correction: Firefox didn’t delete your tabs. You should be implementing some sort of recovery solution.
      For the meantime, have you even tried a right click of the sessionstore.js file & restore to earlier time? Windows uses system restore to back up things like the appdata folder & allow you to not just restore the system to an earlier point, but also individual files & folders.

  12. Andrew Gillett said on March 5, 2015 at 2:23 pm
    Reply

    Here are some tips on how to repair a backed up session which Firefox fails to load:

    https://support.mozilla.org/en-US/questions/1050194#answer-699315

    1. Andrew Gillett said on October 30, 2015 at 11:23 am
      Reply

      I later discovered that all I needed to do in this case (where Firefox fails to remember any tabs) was go to History and look under “Restore closed windows”. That’s dealt with the problem every time since, although it’s still worth making a backup of the profile before trying this.

  13. Millett said on March 11, 2015 at 9:53 am
    Reply

    Congrats, this article explain everything except how to actually restore an old session.

    1. Martin Brinkmann said on March 11, 2015 at 10:04 am
      Reply

      Replace the file sessionstore.js in the main Firefox profile directory with a copy found in the sessionstore-backups folder by renaming the backed up file to sessionstore.js and moving it into the root directory.

      1. PhredE said on August 29, 2016 at 8:16 am
        Reply

        ‘the root directory?!? The root of the system drive?!?
        Martin, for the rest of your life, this is worth remembering – we are NOT all administrators.
        And nor should we be; administer from an admin account, work every day from your everyday account. Basic.
        So you’re saying move another copy of sessionstore.js out of its source folder? Why not just do some renames?

        The extra challenge we have now (mid-2016) with Windows 10 is how these applications handle multiple virtual desktops.
        I was just flipping between two desktops* while Firefox/Nightly restarted, and I’ve lost one window session – I had two on different desktops. That’s looking a problem, don’t you think?
        *CtrlWin left/right

  14. datruche said on October 27, 2015 at 6:33 pm
    Reply

    Thankfull
    For Martin Brinkmann of course: best detailed paper I’ve read and used on the point. And Andrew Gillett for the link that allows to go forward into recovering the [backup].js entries. And Peter’s « less elegant, less automated, but also less error-prone alternative to Session Manager is to use the Bookmark All extension: one click on the Bookmark All button » which makes perfect sense (though you loose the tabs’ navigation history).
    Very small add-ons that ease the job: these that list the tabs (like Tab Grenade) or another that auto-write opened tabs in a dead simple text file every (I think it’s opentabs).

    About KISS, I’ve made a dead simple script that open ‘mc’ on Firefox current profile and a folder so I can backup/copy/rename any needed [restore]*.js files easily (it’s synchronized between my boxes).

    Oh and people like anonymous and bart may get a brain before shouting out.

  15. NJ said on February 18, 2016 at 1:01 pm
    Reply

    Hi,

    Thanks for the above. What if Firefox does not update the sessionstore.js and sessionstore.bak files? We have a system where some of our files are on a central server and some on a local machine. Some of the time the backups work but not always. I just discovered that the last backup was from December so none of my tabs and bookmarks since then are saved. Before closing firefox, how can I ‘save’ a session, i.e. be proactive rather than try to restore after the fact? I’ve read about a session restore add-on but the reviews weren’t great. Happy to do a manual save if that’s an option.

    Many thanks,
    N

  16. Alex said on March 11, 2016 at 10:48 am
    Reply

    Ahhhhhh I’m SO grateful for this! Firefox lost 2 out of my 4 packed windows, was about to despair but renaming previous.js restored all of them!

  17. jonathan said on March 16, 2016 at 6:58 pm
    Reply

    hy
    can i restore my os (which is android) when my firefox is giving me problems

  18. Franck said on March 12, 2018 at 2:43 pm
    Reply

    Thanks a lot, this is very useful !

  19. PLeXiM said on June 6, 2018 at 6:08 pm
    Reply

    You are a saint!

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.