def store_session():
    """ Stores reference backup information for all open tabs into runtime config

    The backup of never stored tabs (state machines) and not stored state machine changes will be triggered a last
    time to secure data lose.
    """
    from rafcon.gui.singleton import state_machine_manager_model, global_runtime_config
    from rafcon.gui.models.auto_backup import AutoBackupModel
    from rafcon.gui.models import AbstractStateModel
    from rafcon.gui.singleton import main_window_controller
    for sm_m in state_machine_manager_model.state_machines.values():
        if sm_m.auto_backup:
            if sm_m.state_machine.marked_dirty:
                sm_m.auto_backup.perform_temp_storage()
        else:
            sm_m.auto_backup = AutoBackupModel(sm_m)
    state_machines_editor_ctrl = main_window_controller.get_controller(
        'state_machines_editor_ctrl')
    number_of_pages = state_machines_editor_ctrl.view['notebook'].get_n_pages()
    selected_page_number = None
    list_of_tab_meta = []
    for page_number in range(number_of_pages):
        page = state_machines_editor_ctrl.view['notebook'].get_nth_page(
            page_number)
        sm_id = state_machines_editor_ctrl.get_state_machine_id_for_page(page)
        if sm_id == state_machine_manager_model.selected_state_machine_id:
            selected_page_number = page_number
        selection_of_sm = []
        for model in state_machine_manager_model.state_machines[sm_id
            ].selection.get_all():
            if isinstance(model, AbstractStateModel):
                selection_of_sm.append(model.state.get_path())
        list_of_tab_meta.append({'backup_meta': state_machine_manager_model
            .state_machines[sm_id].auto_backup.meta.to_dict(native_strings=
            True), 'selection': selection_of_sm})
    global_runtime_config.set_config_value('open_tabs', list_of_tab_meta)
    global_runtime_config.set_config_value('selected_state_machine_page_number'
        , selected_page_number)
