Troubles with cookies

Giganews Newsgroups
Subject: Troubles with cookies
Posted by:  Arthur (olegt…@tut.by)
Date: Fri, 27 May 2005

I think it's error in function TIdNetscapeCookie.IsValidCookie (unit IdCookie).

When AServerHost='signin.half.ebay.com' and FDomain='.ebay.com' - it is valid cookie, but
IsValidCookie drops it.

I modified this function like this:

function TIdNetscapeCookie.IsValidCookie(AServerHost: String): Boolean;
begin
  if IsValidIP(AServerHost) then // true if Server host is IP and Domain is eq to ServerHost
  begin
    result := AServerHost = FDomain;
  end else begin
    if IsHostname(AServerHost) then begin
      //MSIE: if FDomain looks like "xxxx.yyyy.com", then AServerHost "zzzz.xxxx.yyyy.com" is valid
      //eBay: if FDomain looks like ".ebay.com", then AServerHost "signin.half.ebay.com" is valid
      Result := FDomain = RightStr(AServerHost, Length(FDomain));
    end
    else begin
      result := CompareText(FDomain, DomainName(AServerHost)) = 0;
      // result := IndyPos(FDomain, AServerHost) > 0;
    end;
  end;
end;

Now it works well!

Replies