'authorizing another site via PHP only
I've got a site (site A) where PHP scripts generate i.a. links to another site (site B) which is password protected (password required by .htaccess). These links may have forms:
<a href='http://password_protected_site/resource'>
<img src='http://password_protected_site/resource'>
<object data='http://password_protected_site/resource'>
My application - when started - asks user for authorization to site B and after successful athorization everything works as expected. But.... Entering the application on site A is already password protected, so I would like to omit the second authorization done by the user. Instead, I would like my PHP script on site A made this second authorization in background, so for user it would be invisible. Is it possible? If yes, how to do it?
Solution 1:[1]
I would use ajax on button click and redirect the person to another page with authorization headers (Basic Authorization). You can do a redirect like this, and add an authorization header
<?php
ob_start();
$new_url = 'https://example.com/final.php';
header('Location: '.$new_url);
ob_end_flush();
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | boris4682 |
