Hi! Yes, you are correct that when you use wixLocation.to() to redirect to another page on your website, all code execution on the current page will immediately stop.
In the code you provided, there is a danger that the session.setItem line will never run. This is because the wixLocation.to call will redirect the user to a new page before the getName().then promise is resolved and the callback function runs. To avoid this, you can either move the wixLocation.to call inside the then callback, so that it only runs after the session.setItem call has executed, or you can use async/await to ensure that the session.setItem call runs before the redirect.