HTTP authentication from PHP
Posted: Sun Aug 31, 2003 6:42 pm
Hi,
I have a website that’s main index page requires HTTP basic authentication which is currently done through apache. (This I cannot change)
What I am trying to do is create a PHP page that will relocate to this page using the code below and that will automatically log me on using the username and password already in the script.
This redirects me to https://here.there.com however I am then prompted for my username and password.
One possible solution I have tried was:
However this still prompts for a login, thus doesn’t work.
Another tried solution is:
This also does not work!
Does anyone have another solution that might work me?
Any extra information will be most welcome!
Neil
I have a website that’s main index page requires HTTP basic authentication which is currently done through apache. (This I cannot change)
What I am trying to do is create a PHP page that will relocate to this page using the code below and that will automatically log me on using the username and password already in the script.
Code: Select all
<?php
$user = “bob”;
$passwd = “3he4kwf”;
header( “Location: https://here.there.com”);
?>One possible solution I have tried was:
Code: Select all
<?php
$user = “bob”;
$passwd = “3he4kwf”;
header( “Location: https://$user:$passed@here.there.com”);
?>Another tried solution is:
Code: Select all
<?php
$user = “bob”;
$passwd = “3he4kwf”;
header( “Location: https://here.there.com”);
header(“Authorization: Basic “.base64_encode(“$user:$passwd”))
?>Does anyone have another solution that might work me?
Any extra information will be most welcome!
Neil