savinger
savinger

Reputation: 6714

External HTTP Authentication in PHP

Looking to redirect to my university's login page in order to authenticate users with $_SERVER['REMOTE_USER']. Conventionally, I would use an htaccess file to redirect to the login page, but I would like my solution to be completely in PHP. I imagine the start would be...

header('Location:http://login.university.edu');

But I would need to specify the return url, correct? I don't know. I may be completely wrong about this. Any help appreciated.

Upvotes: 1

Views: 723

Answers (2)

Bill
Bill

Reputation: 3209

Careful:

header('Location: http://login.university.edu');
                 ^ space

iirc Header("Location ...") can't specify a query string.

You can use a meta refresh tag of 1 second.

What authentication system does your university use?

Upvotes: 2

Bailey Parker
Bailey Parker

Reputation: 15905

This is not possible in PHP or any other language. It would have to be implemented on your university's system. Most university login systems (especially for WiFi login) allow you to add a return url, but you'll need to ask what the name of this parameter is. My guess would be:

header('Location: http://login.university.edu?return='+urlencode('http://www.mysite.com/page.php'));

Upvotes: 2

Related Questions