XSS vulnerability is exploited because the browser stores the cookie with the session id , so any access to the URL of the site you are logged in, goes with privileges of the logged in user.
What if instead using cookies, we log in the user via the URI, by adding the session on the URI itself? like this:
http://domain.com/123456/index.php?mailbox=Inbox
Here, the "123456" is the session id. For attacker, to exploit XSS this way, it would be much more difficult, because the cookie is not set, and there is no way to access user's URI history.
The drawback is that you have to propagate the session id on the URI for each link when you deliver any page to the user, and if it is lost, the user will be logged out automatically. But this would be more secure.
Can this solution protect from XSS vulnerability?