Hi
Using this code, I successfully set some cookies. I can read them later and they are as well visible in my Firefox inspector.
procedure TWebModule.set_cookie(const aResponse: TResponse; const aName, aValue: string);
var
C: TCookie;
begin
C := aResponse.Cookies.Add;
C.Name := aName;
C.Value := aValue;
C.Expires := Now + 30;
end;
The issue is when I need to delete them. I tried :
procedure TWebModule.delete_cookie(const aResponse: TResponse; const aName: string);
var
I: Integer;
begin
for I := 0 to aResponse.Cookies.Count-1 do
begin
if aResponse.Cookies[I].Name = aName then
begin
aResponse.Cookies.Delete(I);
exit;
end;
end;
end;
This doesn't delete the named cookie, because aResponse.Cookies.Count is equal to 0 or 1.
There is only the
FPWebSession cookie when CreateSession is checked.
But, again, I can read all the cookies I set with
aRequest.CookieFields.Values[aName]
and show them in my internet explorer.
What am I missing or doing wrong ?
Thanks
PS : Of course it is the same with
aResponse.Cookies.IndexOfCookie(aName);