@LarsGit223 my problem with the session file setting mechanism is that I think its potentially very fragile, see for example #2114 that saves session files more often. I think it possible that may foil your cunning scheme by saving the project file with the new file in its session before you can control it.
Thats why I suggested that really you want to intercept the open and decide what to do before it becomes part of the project session files.