4ccf33da61239996702db7af0d93018806b2d38e
angie
  Fri Feb 22 14:04:22 2019 -0800
lastPosition is set by cartHtmlShell* -- but not by other cart openers e.g. cartAndCookie or cartEmptyShell.  CGIs that use the latter must set lastPosition after determining db and position.  refs #22945

diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c
index 2d70c1a..e12fb9f 100644
--- src/hg/hgTables/hgTables.c
+++ src/hg/hgTables/hgTables.c
@@ -402,30 +402,31 @@
     }
 else
     return FALSE;
 }
 
 boolean lookupPosition()
 /* Look up position (aka range) if need be.  Return FALSE if it puts
  * up multiple positions. */
 {
 char *range = windowsToAscii(cloneString(cartUsualString(cart, hgtaRange, "")));
 boolean isSingle = TRUE;
 range = trimSpaces(range);
 if (range[0] != 0)
     {
     struct region r;
+    cartSetLastPosition(cart, range, oldVars);
     isSingle = searchPosition(range, &r);
     if (!isSingle)
 	{
 	// In case user manually edits the browser location as described in #13009,
 	// revert the position.  If they instead choose from the list as we expect,
 	// that will set the position to their choice.
 	char *lastPosition = cartUsualString(cart, "lastPosition", hDefaultPos(database));
 	cartSetString(cart, "position", lastPosition);
 	}
     }
 else
     {
     cartSetString(cart, hgtaRange, hDefaultPos(database));
     }
 return isSingle;