Reputation: 403
I would just like to find a way in PHP (a link, a button, etc.) to give the user the possibility to open a (http-authentication-based) password protected page.
I already tried with a simple href containing the link to:
http://username:password@domain
but it seems it does not work anymore in current browsers.
Is there a way to do this? It seems a very trivial problem, but actually I still have not found a way.
Thank you.
Upvotes: 1
Views: 1360
Reputation: 25249
As you say, the username:password
scheme won't work accross all browsers. What you can do - if you don't mind a script based solution - is to establish authentication via AJAX first, then present the user a normal link.
Idea outlined:
Upvotes: 1
Reputation: 1384
Don't know why this should not work. Possible security issues that modern browsers are trying to avoid.
But to get this done, you could use
<script>
function foo(){
window.location = "http://username:password@domain";
}
</script>
<a onclick='foo()'>Click here</a>
Upvotes: 0