This is an interesting question, and it turns out to be a little more difficult if you read not only the title, but also the text of the question itself.
To answer it requires an understanding of how PHP works in principle .
therefore, there will be two answers:
- Of course, you can remove an element from a superglobal array.
- But this will not help you.
Since these variables are filled again with each request, from the incoming HTTP headers. That is, the question really sounds like
Is it possible to force the browser not to transmit a specific HTTP header?
Answer: it is impossible.
HTTP basic authentication is designed so that the browser transmits a username and password with each request. If he does not transmit them, the PHP script will not recognize them, and the user will not be able to view the password-protected page.
In this case, the logout mechanism in HTTP basic authentication is not provided.
You can only request the password again, but if the user ignores this request, the browser will continue to send the old login and password. About 15 years ago I’ve been digging this topic for quite a while, and even made a demo page that didn’t log out the user ... but the most capable could find out that this trick was performed using a banal cookie 8)