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?
-
Possible duplicate of [What is the maximum size of a web browser's cookie's key?](http://stackoverflow.com/questions/640938/what-is-the-maximum-size-of-a-web-browsers-cookies-key) – Jerry Dodge Oct 06 '16 at 15:10
-
Split it into different cookies. – Jerry Dodge Oct 06 '16 at 15:15
-
Or switch to [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage) – Stijn Sanders Oct 06 '16 at 15:50
-
I know about browser's cookie limits. I know that the most of the browsers do not support large cookies but it is possible that the DLL can receive large cookies. this has happened with my DLL. Does Delphi have anything to handle large cookies? – Illya Pavlov Oct 06 '16 at 16:02
-
I would think the limitation is in ISAPI, not your DLL. I'm not 100% sure about that though. – Jerry Dodge Oct 06 '16 at 16:08
1 Answers
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.

- 1,146
- 12
- 23