Parameter restartApplication and theme

We have an application with a login page.
To access the application, the parameter
“restartApplication”
is added to ensure clean session.

After login page, a specific theme can be set according to the user logged in.

If another theme is set, the page is reloaded. And if the parameter
“restartApplication”
was present when accessing the application, the user is automatically redirected to the login page which is the logout URL of the application, which is not the desired behavior.

Could someone help us please?

Thank you in advance!