简体   繁体   中英

Cookie size limit. Large cookies

I'm using ISAPI DLL and met a situation when the DLL's TWebRequest.Cookie shows no cookies at all if total cookie size is greater than 4096 bytes. Is there a way to handle large cookies?

In Delphi, there is no way, unless you implement your own ISAPI layer (something that IntraWeb does). Everything based on built-in ISAPI layer (TISAPIRequest/TISAPIResponse) cannot handle it, because of how it retrieves the cookie field from the request. The method is TISAPIRequest.GetFieldByName() (unit Web.Win.IsapiHTTP):

function TISAPIRequest.GetFieldByName(const Name: AnsiString): AnsiString;
var
  Buffer: array[0..4095] of AnsiChar;
  ...
begin
  ...
end;

Please notice that Buffer var - which will get the actual data - is limited to 4096 bytes. That's why you can only receive this amount of data in your cookie. I don't see how you can receive more data, unless you split it into more than one cookie.You can also send data using custom fields (which are much easier to create/manipulate from the browser side), like "X-Example-Your-Data: abcde" (also limited to 4096 bytes). You can retrieve this data using the same GetFieldByName() method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM