Modeling a cookie-enabled browser in PHP

How to open a web page and get its cookies using PHP?

Motivation : I'm trying to use feed43 to create an RSS feed from a non- HighLearn Web site with RSS support (distance learning site). I found a web page containing the contents of the feed that I need to analyze, however, this requires a login first. Fortunately, you can log in with a GET request, so it's easy, like fopen () ing " http://highlearn.website/login_page.asp?userID=foo&password=bar ". But I still need to get the cookies generated at login , pass the cookies to the real client (using setcookie (), maybe?), And then redirect.

+3
source share
3 answers

HTTP- cURL. cookie . , (curl_multi) .

, , . cookie . , .

+5

Scriptable Browser Simpletest . .

( , ). PHP- script - .

+1

Unfortunately, this is not possible if the websites are not in the same domain. Cookies are valid only for the domain from which they were created. In addition, subdomains are considered different domains. Otherwise (remember I didn’t use a lot of php) you could pull the headers from the response and copy the cookie to the client.

0
source

Source: https://habr.com/ru/post/1699698/


All Articles