as you know, google shows different search results for different cities. For example searching for particular keyword with location set to Washington will give you different results comparing to e.g. New York. So let's say that I want to have script, which will pass cookie file with location to google, to easily check positions of keywords in different areas.
When I set my location to polish city "szczecin" google sends these two cookies to my computer (they're exported in json from Edit this cookie chrome extension):
[{
"domain": ".google.pl",
"expirationDate": 1391874587.99004,
"hostOnly": false,
"httpOnly": true,
"name": "NID",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "67=PnzEVGrTahfTXSlj5SMggJqdu7Vw8Q9D4PlVkYQE6gIZdA8BV3S1je-Ub5m-wEYuiJ1AvX_WAdZbxTErDUqhI1Nsil7VjcMxyizZbcI4Vhu7afewuOKnBMcCpnn2v4sH"}],
{
"domain": ".google.pl",
"expirationDate": 1439143350.316524,
"hostOnly": false,
"httpOnly": false,
"name": "PREF",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "ID=9defb5b796bd355d:U=642baf734973f22a:FF=0:TM=1376060070:LM=1376071350:L=1c3pjemVjaW4:S=8S3gsGjYc6Tm_1S-"
}]
When I want to change my location for example to another polish city "Katowice", the crucial difference is that in the PREF cookie now is L=0Z1J2H5YI instead of L=1c3pjemVjaW4. When I my location is set to Szczecin and I replace L=1c3pjemVjaW4 with L=0Z1J2H5YI in edit this cookie extension, the location is Katowice again. Using this knowledge I want to set location with curl. I'm doing it this way:
$cookie = "domain=.google.pl; hostOnly=FALSE; httpOnly=FALSE; expirationDate=1439135045; name=PREF; value=ID=9defb5b796bd355d:U=57ea2c0f55adb400:FF=0:TM=1376060070:LM=1376062249:L=0Z1J2H5YI:S=iaCmsUGcGZUHeQvh;";
$ch = curl_init( $wyniki_url );
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_close( $ch );
But it seems to have no impact on search results - they're still defined by ip location instead of this cookie. Any opinion what am I doing wrong, cause probably something fails with sending this cookie via curl? Thanks for any help.
After a quick look of the cookie, I believe S=
part is a signature that prevents you from setting cookie yourself. So google server can tell if the cookie has been changed thus you are not getting the result.