I am trying to obtain some information from a webpage that requires login. I am using PHP/cURL to post username and password to the login page on the target website. The website uses relative links to redirect authenticated users to a members only area.

I am getting 200 OK and I can see that I am being successfully authenticated. My issue is that I don't know how to make it go to the actual member area in the target website (targetwebsite.com/memberarea) as opposed to mywebsite.com/memberarea. Is there a way to specify the base domain of the target website in cURL? Could you also tell me if I am doing something not recommended in the following code.