Skip navigation.

bpm's Operations Room

understanding & extending Opera

Better sessions functions you've never seen (and post-crash session recovery)

(last edited 2009-11-7)(Note: this pertains only to Opera for Windows.)

This post will:
  • introduce you to existing functions which allow you to see all saved sessions, see dates and sizes, sort chronologically, and navigate to sessions files in other folders;
  • explain a quirk which normally makes it impossible to recover what you had open before a crash if you use the "open with home page" setting, and how to work around it;
  • provide a little DOS utility to open Opera quickly with no pages, even if you use "resume from last time" - without losing your last session.
  • explain how to read session files within Opera.

A sessions file is a snapshot of your window state which preserves not only the URLs of the pages you have open, but also the history of each tab that you navigate with the Back and Forward buttons (which may amount to hundreds of URLs), and sizes and locations of the tabs if they are not maximized. It can provide a very handy way back into complex scenarios. However, a system like this loses a lot of its usefulness if the interface isn't rich enough to convey what you need to know to exploit it.

That basically is true of the sessions functions you see in Opera's standard setup ("sessions" menu, and the "manage sessions" item on it). They are an unfortunate departure from normal file management, which dumbs your awareness and control of the session system down to a rudimentary level.



Using them, you:
  • can't see dates or sizes
  • can't sort into chronological order
  • can't rename sessions files
  • can't access sessions files outside the default folder
And the most prominent saved-sessions list omits the most important one - the autosaved session - which of course confuses people into thinking that autosave is not happening or that the autosaved session is not accessible.

Better functions - which hand file management over to Windows - already exist, tucked away in Opera. Here's what they look like: normal Windows folders. The one on the left shows the familiar rightclick menu, through which files may be renamed or deleted; the one on the right shows an optimized view mode: Details view (date and size listed), File Type changed to All; in alphabetical order, which can be changed to chronological by clicking the "Modified" header:



Obviously, dates and file size can be useful for finding a saved session if you know what you're looking for. And the ability to rename permits you to keep an extensive list organized.

You can also navigate to other folders, and open sessions from within them:



You can use this, for example, to open sessions from one Opera installation in another. Once you're aware that folder navigation is possible, you're free to develop archive folders (such as snapshots of your research into some topic) and organized folder trees of sessions to rival your bookmark collection if that is useful to you - and email sessions to friends and coworkers.

The hidden backup file
Switching the File Type to All Files produces a small surprise: revealing the existence of a file called autosave.win.bak. Evidently Opera is doing some sort of backup. It's not clear how useful this is, or what triggers its refresh; in my system, it's three days old. However, it's there - and if some tragic crash or slip of the finger wipes out something of value, you may as well be aware of all the places you can look.

The fix
The commands are "open session" and "insert session"; you can as usual attach them to keystrokes, mouse gestures, menu lines or toolbar buttons. Here they are as buttons: OpenSession; InsertSession.

To add them to the current Sessions submenu of the File menu, set up a custom Menu.ini if you haven't (as described by Tamil here) and add these lines to the [Browser Session Menu] section:
Item, "Open session (in added window)" =open session
Item, "Insert session (within current window)" =insert session

(Captions clarify fact that neither function closes any pages.)

Why did Opera even develop an Internal List, and a dialog, when standard infrastructure does the job better? And why now promote it over the more capable functions? Life is a labyrinth to which we lack a map...

the lore of sessions
  • if you associate the WIN extension with Opera in Windows (in Windows Explorer: Tools/Folder options/Filetypes/New), then clicking a sessions file will launch Opera with that session. So you can use shortcuts and links to sessions files as ways of opening Opera in desired states.
  • a quirk: the "start with home page" setting overwrites autosave.win during startup, replacing it with the session it is setting up: home page and nothing else. So, although there is a Previous Session in the Manage Sessions dialog, it is of no use after a shutdown or crash. To get around this, the best method is register Opera to open sessions; then clicking autosave.win (or a shortcut to it, which may be worth having on your desktop or quicklaunch toolbar) after a crash will open the session that existed before the crash.
  • the opposite case was troubling someone on the forum: wanted to be able to open Opera quickly despite use of "resume from last time" setting, without opening or losing the autosaved session. Solution, in this post: a DOS file that renames autosave.win for later use, copies an empty session as autosave.win, and launches Opera. Clicking a shortcut to it thus preserves last session (there on sessions menu when wanted) and provides quick startup. To use it, save an empty session as empty.win; copy the DOS file into your system (suggested location: C:\utility; procedure as described in DOS backup post) and make a shortcut to it:
    EmptyOpera.bat
    cd C:\"Documents and Settings\martimer\Application Data"\Opera\Opera\sessions
    copy autosave.win oldauto.win /y
    copy empty.win autosave.win /y
    start c:\"program files"\Opera\Opera

  • two former flaws in the sessions system have been fixed in Opera 10. The sessions menu used to be in an unexplained random order; it is now alphabetized. And the Internal List used to be generated from the Sessions folder at startup, and maintained based on the assumption that sessions were only added by Saving, and only deleted through the Manage dialog. If sessions were added or deleted by other means the list became outdated. A session someone emailed you, for example, copied into the sessions folder, would not show up until a restart. Now the list updates after file operations.
  • like most of Opera's system files, sessions files are text files and not hard to open and read. In fact, you can read them within Opera: just browse to your Opera folder, open the sessions folder within it, and click on a filename. This won't launch the session: it will open it as a text page. If you're not familiar with file browsing in Opera: just type c: in the address field, and press Enter - you've got a folder listing, and can click your way into it. To get to your Opera folder quickly, go to Help / About Opera; copy the path given there for the Opera folder; paste into address field and click Enter.
  • it is possible to open sessions with a direct command. The command is "Select session,#": with an actual number replacing the symbol. -1 shows dialog, 0 opens autosave.win and other numbers open nth session from list you see on the menu (in a new window). So with discipline (must avoid using session names alphabetically before those you want stable access to) you can have hardcoded sessions commands.
  • opening sessions by name: since you can launch Opera with a session by executing the session file in Windows, what happens if you use Opera's Execute command to try to launch a session by name? If Opera is still running (which is what a direct Execute command achieves), the effect is to open it as a file. But this works: exit & execute program,"C:\documents and settings\username\application data\opera\opera\sessions\named_session.win" That shuts Opera down first, and then executes the session file - which starts Opera up again, session loaded. Baroque, but it is a way to have session commands that work.

Showcode: click to see inside toolbars and menusMy macros

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.