Question

I'm using Idhttp (indy10 with delphi-xe2) to post form, but I get session expired message from the site, although I've already set cookie manager. Thank you.

procedure TForm2.IdCookieManager1NewCookie(ASender: TObject; ACookie: TIdCookie;
var VAccept: Boolean);
begin
  ShowMessage(Acookie.CookieText);
end;

The result from ShowMessage is: ASP.NET_SessionId=enn1xnqde1o1rduedels5fqp; Path=/; Domain=www8.ticketingcentral.com; HttpOnly; Max-Age=252028195945; Expires=Fri, 31-Dec-9999 16:59:59 GMT

Was it helpful?

Solution

When both Max-Age and Expires are present in a cookie, Max-Age takes priority and Expires is ignored, per RFC 6265. Max-Age is expressed in seconds from the current clock time. A Max-Age value of 252028195945 is ~7991 years in the future! Adding that the current clock creates a date in the year 10004, which TDateTime cannot represent (9999 is the highest year it supports). So you are likely getting a rounding issue with the expiration date being set to a negative value, thus representing a date in the past, not the future, thus expiring the cookie before it can ever be sent back to the HTTP server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top