Bug - Fixed Inventory cookie doesn't work

Veracity

Developer
Staff member
I noticed this on the G-D thread; I'm not allowed to post there, but I can read, so I look at it, now and then.

There is a KoL Inventory option to open the inventory with the sections collapsed. Note that this doesn't actually cut down on server hits; the whole inventory, including images, is on the page response - and the browser will request all those images - but the sections are not shown until you click "expand this section" and the brower opens it with Javascript.

In the Relay Browser:

(with this option checked)
- Go to Inventory
--> The sections are collapsed
- Go to a different section of inventory
--> The sections are not collapsed.

I turned on debugging, including Browser interactions, and saw this:

Code:
-----From Browser-----
GET /inventory.php HTTP/1.1
Requesting: https://www.kingdomofloathing.com/inventory.php
Field: Cookie = [session-set=true; PHPSESSID=xxxx; AWSALB=yyyy]
Retrieved: https://www.kingdomofloathing.com/inventory.php
Field: Set-Cookie = [inventory=16775167; path=/; domain=.kingdomofloathing.com, AWSALB=zzzz; Expires=Thu, 16 Mar 2017 13:10:31 GMT; Path=/]
-----To Browser-----
Set-Cookie: inventory=16775167; path=/; domain=.kingdomofloathing.com
Set-Cookie: AWSALB=zzzz; Expires=Thu, 16 Mar 2017 13:10:31 GMT; Path=/
Notice that KoL gave us an inventory cookie:

inventory=16775167; path=/; domain=.kingdomofloathing.com

Notice that we passed it down to the browser.

Going to a different session:

Code:
-----From Browser-----
GET /inventory.php?which=3 HTTP/1.1
Cookie: AWSALB=zzzz session-set=true
Requesting: https://www.kingdomofloathing.com/inventory.php?which=3
Field: Cookie = [session-set=true; PHPSESSID=xxxx; AWSALB=zzzz]
Retrieved: https://www.kingdomofloathing.com/inventory.php?which=3
Field: Set-Cookie = [AWSALB=wwww; Expires=Thu, 16 Mar 2017 13:10:45 GMT; Path=/]
-----To Browser-----
Set-Cookie: AWSALB=wwww; Expires=Thu, 16 Mar 2017 13:10:45 GMT; Path=/
Notice that the browser did not include the inventory cookie in its request.
Therefore, we did not forward it to KoL.
Therefore, KoL did not collapse the inventory session.

I imagine that the issue is the "domain=.kingdomofloathing.com" that KoL specifies that we dutifully pass down to the browser. The browser doesn't think it is connecting to that domain. It is connecting to 127.0.0.1:60080

KoLmafia used to have special handling for two cookies:

PHPSESSID
inventory

When KoL started including AWSALB, which changed for every single request, I whacked the code to generalize cookie handling. We recognize PHPSESSID and AWSALB as "special cookies" which we will store and automatically include, but we let the browser handles any other cookies.

I see a couple of options:

- Handle the "inventory" cookie similarly and include it for /inventory.php. Presumably, delete it if KoL deletes it
- Rewrite the domain from .kingdofloathing.com to something that the browser will recognize as what it is connected to.
 

Veracity

Developer
Staff member
Revision 17883 simply removes a ".kingdomofloathing.com" domain from a Set-Cookie. That works in this case.
I will experiment with replacing the domain with 127.0.0.1:pORT.
 

Veracity

Developer
Staff member
That works too and keeps the semantics of actually specifying a domain.
Revision 17994.
 
Top