Cookie monster

TorgoX on 2002-02-13T17:54:28

Dear Log,

I never cease to be amazed at how as simple a protocol as HTTP requires such complex code to implement correctly, and even how hard it is to decide what "correctly" means. Last night I was rooting around in LWP/UserAgent.pm trying to fix a problem that was basically this: This one web site needs certain cookies which it uses for a session ID. But if the session ID is old enough, it wants to change the cookies. So you access page X, it sees you have an old session ID, it HTTP-redirects you to page Y, the response to which is just setting a new cookie and HTTP-redirecting you to page X, which this time succeeds. LWP/UserAgent.pm thinks that's a loop, and won't obey the redirection from page Y, because why would you want to hit a URL that you were just redirected away from? So I have to add code that implements the idea that Oh, but THIS time you'll have a different cookie, so it'll be probably be okay! Sheer lunacy. But necessary.


Another solution

autarch on 2002-02-13T18:24:49

It seems like the loop detection code is just to simplistic.

Instead of balking at X, Y, X, how about making it smart enough to detect something like:

X, (...), X, $1, X

if you get my drift.

If you hit the same full series of pages twice in a row and _then_ ended up where you started, that sounds like a more sure loop.