3

When I close FF via CMD:

Process process = Runtime.getRuntime().exec("taskkill /F /T /PID " + PID);

And reopen FF I get the following:

Sorry, we're having trouble getting your pages back... We are having trouble restoring your last session. Select Restore Session to try again...

I see the option to Restore Session or Start New Session.

Firefox: Sorry, we're having trouble getting your pages back..

My question is: Does this imply that FF was unable to preserve cookies or any other persistent data from the previous session or it solely means that FF will restore pages from the previous session? As far as I can tell cookies are preserved because when I go to options -> privacy and security -> manage data I see cookies from the previous session. To phrase my question a bit differently, if I chose NOT to restore the previous session is there any way for a website (that I visited in the previous session) to tell that I did not restore the previous session (i.e, based on cookie data or some other persistent data)?

  • You already inspected the page data when restoring a session - did you inspect the page data when starting a new session!? – luk2302 May 30 '21 at 16:35
  • @luk2302 Yes, I inspected the cookies when starting a new session, not when restoring. As far as I can tell the cookies are being preserved even w/o restoring previous session . Am I right? Is there any other persistent type of data that a website might use to track its users _that may not be restored_ if I chose to start a new session? – Laurence Gretsch May 30 '21 at 16:38
  • @luk2302 In other words, exactly _what_ is being restored when I choose to "restore previous session"? Just a bunch of web pages or other browsing data? – Laurence Gretsch May 30 '21 at 16:45
  • 1
    Please remove the `taskkill` option `/F` which __forces__ a brutal __kill__ of the `firefox` process with specified process identifier and all its child processes because of option `/T` by the operating system without giving __Firefox__ the chance to gracefully __terminate__ itself and save all unsaved data. That is for __Firefox__ on next start like it has crashed before. `%SystemRoot%\System32\taskkill.exe` sends the [WM_CLOSE message](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-close) to __Firefox__ on not using option `/F` on which __Firefox__ terminates itself gracefully. – Mofi May 30 '21 at 19:27
  • The usage of `taskkill` option `/F` gives __Firefox__ no chance to close all currently open connections to web servers, quit all running threads, close opened files, save the user session according to the user´s configuration, etc. This is the reason why __Firefox__ informs the user on next start with this message that it could not save the user´s session (open windows/tabs) on last run and restore it now on this start with detection of previous run ended abnormal. The reason is not the fault of __Firefox__, it is your fault as you __kill Firefox__ instead of let it self-terminate. – Mofi May 30 '21 at 19:36
  • BTW: In the __Options__ of __Firefox__ in window __General__ there is at top in section __Startup__ the option *Restore previous session* which can be unchecked by the user. This option is documented on page [Restore previous session - Configure when Firefox shows your most recent tabs and windows](https://support.mozilla.org/en-US/kb/restore-previous-session). – Mofi May 30 '21 at 19:43
  • The usage help of command __TASKKILL__ is output on running `taskkill /?` in a command prompt window. The command [taskkill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill) is documented also by Microsoft referenced on [Windows commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands) page and by [SS64.com - A-Z index of Windows CMD commands](https://ss64.com/nt/) on the [TASKKILL](https://ss64.com/nt/taskkill.html) page. – Mofi May 30 '21 at 19:46
  • Which data __Firefox__ could save already before being brutally killed by the operating system in a file is out of control by __Firefox__ and of course also by websites with client-side stored data and client-side executed code on using the command `taskkill` with option `/F`. – Mofi May 30 '21 at 19:51
  • @Mofi Thanks for your comments **1) RE:** "In some cases the cookies might be unbaked.." Assuming Firefox was brutally killed _while idle_ or long after a cookie might have been received (thus, it is safe to assume that all cookies received were already saved to file) is there any reason to assume that the cookie data might be unbaked or corrupted? If yes, why? **2) RE:** "taskkill option /F gives Firefox no chance to close all currently open connections to web servers" Can a website detect when a connection is forcefully closed (assuming cookie data was preserved)? If yes, how? – Laurence Gretsch May 30 '21 at 22:54
  • @Mofi **3) RE:** "BTW: In the Options of Firefox in window General.." What does _Restore Previous Session_ do? If the cookies were corrupted can this option restore corrupted cookies? Or, as stated in the OP, it simply restores the previous web pages? – Laurence Gretsch May 30 '21 at 23:12
  • @Mofi **4) RE:** "Remove the taskkill option /F which forces a brutal kill of the firefox" I cannot remove the the option `/F` because I'm using it to terminate FF instance that was launched through `WebDriver` and there are cases when `WebDriver` does not respond to `driver.quit()` [as described in this question](https://stackoverflow.com/q/57793476/16073226). Thus, unless I forcefully destroy `WebDriver` the number of instances of `Geckdriver` will grow unchecked in `Task Manager`. Also see [this question](https://stackoverflow.com/q/58724146/16073226) as to why `/F` option is required. – Laurence Gretsch May 30 '21 at 23:16
  • 1
    I am not a Firefox programmer and so don´t know what they have done to prevent complete data loss on Firefox crashes or is killed by the operating system, for example during updating a *.sqlite database file like `cookies.sqlite` or `places.sqlite`. It could be that cookies are saved already on Firefox being killed after a long idle time or after a longer time on cookie data have been received, but I don't know that for sure. The operating system closes all sockets (TCPm UDP sockets) and also all files. A website has usually no possibility to find out why socket was closed on the other side. – Mofi May 31 '21 at 06:08
  • 1
    If the kill of Firefox is done by the operating system during Firefox writing into `cookies.sqlite`, the entire database could be corrupted in a manner making it impossible to load any data from this file on next start. I don´t know if Firefox takes precautions to avoid a total loss of data on being killed or crashing itself during data saving process, for example by creating a backup of existing database file before opening the real database file for write operation to be able to use the backup on next start on being killed or crashed during write operation of the real database file. – Mofi May 31 '21 at 06:13
  • @Mofi thanks so much for your reply. Do you have any insight regarding the 4th question -> **4) RE:** "_Remove the taskkill option /F which forces a brutal kill of the firefox_" I cannot remove the the option `/F` because I'm using it to terminate FF instance that was launched through `WebDriver` and there are cases when `WebDriver` does not respond to driver.quit() as described in this question. Thus, unless I forcefully destroy `WebDriver` the number of instances of `Geckdriver` will grow unchecked in `Task Manager`.. – Laurence Gretsch May 31 '21 at 16:12
  • 1
    I don´t use Selenium and WebDriver. So I can´t help regarding to what could be done regarding to WebDriver on not being responsive because of a deadlock (no CPU core usage) or an endless loop (massive CPU core usage). Well, it should be possible to gracefully terminate Firefox and just kill WebDriver and its child processes. Or there are terminated the instances of Geckdriver with `taskkill` if that is possible at all and then this results perhaps in WebDriver terminating itself gracefully, too. But I can´t really suggest something as not using these applications at all. – Mofi May 31 '21 at 16:49

0 Answers0