Reputation: 61
I am using php curl to view this webpage remotely http://agentnet.propertyguru.com.sg/ex_login?w=1&redirect=/ex_home
The page redirects to another page /distil_identify_cookie.html?uid=... before redirecting back to the initial login page
I have set the following in my curl script
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, FALSE);
This did not stop the page from redirecting.
Can anyone advise how I can store this $_GET variable "uid" in a cookie before the page redirects?
Add:
After executing the curl statements ($response = curl_exec($ch);), $response is as per below
HTTP/1.1 200 OK Server: nginx Date: Sun, 06 Jul 2014 08:47:32 GMT Content-Type: text/html
Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 19 Nov 1981 08:52:00 GMT Pragma: no-cache
Set-Cookie: PHPSESSID2=94l8r0sainetrrc3vl0r7dl2f4; path=/; domain=.propertyguru.com.sg
Set-Cookie: __PAGE_REFERRER=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=agentnet.propertyguru.com.sg
Set-Cookie: __PAGE_SITE_REFERRER=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=agentnet.propertyguru.com.sg
Vary: Accept-Encoding X-Distil-CS: MISS
I cannot find anything in the header stating the uid value...
Upvotes: 1
Views: 287
Reputation: 906
You can set both CURLOPT_FOLLOWLOCATION and CURLOPT_HEADER to TRUE. This way, in the final result you`ll have the headers for all redirects that happen during your request. Then, you can parse the headers to get the info you need.
Upvotes: 1