This is in reference to this earlier StackOverflow question, login credentials, where Tom B. suggested using this format for logging in through HTTP/HTTPS: username:password@domain.com.
This approach leaves the username and password visible to anyone who inspects the page source.
Is there any way to perform the initial login through PHP (perhaps cURL), and then proceed with the HTML session? I tried the following, but for some reason, the session is not saved, causing the proceeding HTML to fail:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://url.xxx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
curl_close($ch);
include 'sessionPage.html';
?>
This format didn't work either:
curl_setopt($ch, CURLOPT_URL, 'http://user:password@url.xxx');
How could I perform a successful login through a PHP script and have the session carried forward to the proceeding HTML page? The resource is third-party, so I have no control over the session information.
Thank you.