be4311c07e14feb728abc6425ee606ffaa611a58
markd
  Fri Jan 22 06:46:58 2021 -0800
merge with master

diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index f9cd742..8202c14 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -3463,31 +3463,33 @@
 /* get the current position in cart as a string chr:start-end.
  * This can handle the special CGI params 'default' and 'lastDbPos'
  * Returned value has to be freed. Returns 
  * default position of assembly is no position set in cart nor as CGI var.
  * Returns NULL if no position set anywhere and no default position.
  * For virtual modes, returns the type and extraState. 
 */
 {
 // position=lastDbPos in URL? -> go back to the last browsed position for this db
 char *position = NULL;
 char *defaultPosition = hDefaultPos(database);
 struct cart *lastDbPosCart = cartOfNothing();
 boolean gotCart = FALSE;
 char dbPosKey[256];
 safef(dbPosKey, sizeof(dbPosKey), "position.%s", database);
-if (sameOk(cgiOptionalString("position"), "lastDbPos"))
+
+// use cartCgiUsualString in case request is coming via ajax call from hgGateway
+if (sameOk(cartCgiUsualString(cart, "position", NULL), "lastDbPos"))
     {
     char *dbLocalPosContent = cartUsualString(cart, dbPosKey, NULL);
     if (dbLocalPosContent)
 	{
 	if (strchr(dbLocalPosContent, '='))
 	    {
 	    gotCart = TRUE;
 	    cartParseOverHash(lastDbPosCart, cloneString(dbLocalPosContent)); // this function chews up input
 	    position = cloneString(cartUsualString(lastDbPosCart, "position", NULL));
 	    }
 	else
 	    {
 	    position = dbLocalPosContent;  // old style value
 	    }
 	}