php curl到页面,并在页面重定向之前将$_GET变量存储在cookie中


php curl to page and store $_GET variable in a cookie before page redirects

我正在使用php curl远程查看此网页http://agentnet.propertyguru.com.sg/ex_login?w=1&redirect=/ex_home

页面重定向到另一个页面/distil_identify_cookie.html?在重定向到初始登录页面之前

我在curl脚本

中设置了如下内容
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, FALSE);

这并没有阻止页面重定向。

谁能建议我如何存储这个$_GET变量"uid"在cookie页面重定向之前?

添加:

执行完curl语句后($response = curl_exec($ch);), $response如下

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

CURLOPT_FOLLOWLOCATION和CURLOPT_HEADER都可以设置为TRUE。这样,在最终结果中,您将获得请求期间发生的所有重定向的标头。然后,您可以解析标题以获得所需的信息。