views:

210

answers:

1

I'm trying to redirect to a page that uses basic authentication, with no success so far. Most examples I found online where to either use fopen or curl to request a resource, which I don't want to do.

I've tried putting in the header the "Authorization: Basic" plus the encoded user:password, but it didn't work. Is it because I first need to receive a request from the other page for the authorization credentials?

+1  A: 

No. It's because it's just impossible. You send these headers to the browser, and browser don't know what to do with it.

Direct request feature (using login:pass@ notation) was removed, due to excessive phishing usage.

So, do just usual redirect and then let user to enter their password.

Col. Shrapnel
Unfortunately that's not an option, as the user can't be prompted. I guess I'll have to convince them to use a different authentication method.
nevizi
@user299090 it wont help you too much
Col. Shrapnel
http://www.peej.co.uk/sandbox/htmlhttpauth/This guy does this using Javascript, so are you sure it's not possible using PHP?
nevizi
@user299090 I'm damn sure. Because it is browser who need this authorization. Not PHP. PHP sits on the server, far away from the browser. You can authorize PHP with this site but you need to authorize browser, not PHP
Col. Shrapnel