SetCookies()/AddCookie()/GetCookies() not working
Posted: 2021-04-02 12:08:57
During my tests with the Google "Bad Request" response, I figured out that Google needs acceptance to use cookies. To do this, I tried to use SetCookie() or GetPage3() to add this needed cookie. But the functions don't work.
Hint: Workaround to use Google without cookie acceptance: Use http:... instead of https:... But don't now, how long this work.
To test cookies, try:
ShowMessage() shows an empty String. No Cookie.
And my Proxy shows as the first request (in later requests a cookie is send, because google set it in the first response. But this is not my added cookie. To clean the cache, close and reopen the scripting-window)
No Cookie set. I've expected:
Whats wrong?
Greetz,
yeti
Hint: Workaround to use Google without cookie acceptance: Use http:... instead of https:... But don't now, how long this work.
To test cookies, try:
Code: Select all
procedure Test();
var
Page, Address: string;
begin
Address := 'https://www.google.de/search?q=allintext%3A+Holy+Motors+%22Inhaltsangabe+%26+Details%22+site%3AFilmstarts.de/kritiken/';
SetCookies('TESTCOOKIE=ANTTest', 'www.google.de');
ShowMessage('Cookies: "' + GetCookies('www.google.de') + '"');
Page := GetPage(Address); // Bad Request
//Page := GetPage3(Address, '', 'TESTCOOKIE=ANTTest'); //<-- no cookie send, too
end;
And my Proxy shows as the first request (in later requests a cookie is send, because google set it in the first response. But this is not my added cookie. To clean the cache, close and reopen the scripting-window)
Code: Select all
GET https://www.google.de/search?q=allintext%3A+Holy+Motors+%22Inhaltsangabe+%26+Details%22+site%3AFilmstarts.de/kritiken/ HTTP/1.1
Content-Type: */*
Accept: text/html, */*
User-Agent: Mozilla/5.0 (compatible; Ant Movie Catalog)
Authorization: Basic Og==
Proxy-Authorization: Basic Og==
Host: www.google.de
Code: Select all
GET https://www.google.de/search?q=allintext%3A+Holy+Motors+%22Inhaltsangabe+%26+Details%22+site%3AFilmstarts.de/kritiken/ HTTP/1.1
Content-Type: */*
Accept: text/html, */*
User-Agent: Mozilla/5.0 (compatible; Ant Movie Catalog)
Authorization: Basic Og==
Proxy-Authorization: Basic Og==
Host: www.google.de
Cookie: TESTCOOKIE=ANTTest
Greetz,
yeti