I apologize in advance, as I’m sure I’m going to explain this situation horribly, since most of this is new to me.
TL;DR: I have a PHP script that retrieves the HTTP headers for a list of domains (using get_headers), but recently the owner of the domains setup language detection which has now somewhat broken the script. Instead of following the HTTP header path and stopping, it now just keeps repeating the last HTTP Location header until it times out, since the script isn’t accepting the language cookie to stop get_headers from running.
The script looks for the Location headers and would eventually return something like this after traversing the HTTP headers.
http://example_com -> httpS://example_com -> https://WWW.example_com
And then it would stop running and move on to the next domain.
However now the following information is sent by the domains in order to set the language in a cookie
Set-Cookie: LANGUAGE=en;Path=/;Domain=.example.com;Secure
Set-Cookie: DEFLANG=en;Path=/;Domain=.example.com;Secure
and if this information isn’t used the last HTTP Location header request (in this example, https://www.example.com), just keeps repeating. This is happening because the language isn’t getting set so the domain doesn’t know where to redirect the script.
I was able to find a semi-workaround, where the script, after traversing all of the HTTP headers, uses all of the Location headers but then cuts off when they start to repeat. However, this means I still need to run get_headers until it times out, which is the issue I’m now trying to solve, as the script runs for much, much longer than it used to, and I’m constantly getting excessive resource usage warnings from my web server.
So my question is, is there any way to set/simulate this cookie information
Set-Cookie: LANGUAGE=en;Path=/;Domain=.example.com;Secure
Set-Cookie: DEFLANG=en;Path=/;Domain=.example.com;Secure
before I run get_headers, so that the domain will see the language as English and act accordingly, instead of continually looping on the last HTTP Location header?