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/inc/cart.h src/hg/inc/cart.h
index 8435ba6..51202be 100644
--- src/hg/inc/cart.h
+++ src/hg/inc/cart.h
@@ -628,24 +628,29 @@
 /* Hide all the tracks who have default visibilities in trackDb
  * that are something other than hide.  Do this only if the
  * variable CART_HAS_DEFAULT_VISIBILITY is set in the cart.  */
 
 char *cartGetPosition(struct cart *cart, char *database, struct cart **pLastDbPosCart);
 /* 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 
  * if no position set in cart nor as CGI var.
  * For virtual modes, returns the type and extraState. 
 */
 
 void cartSetDbPosition(struct cart *cart, char *database, struct cart *lastDbPosCart);
 /* Set the 'position.db' variable in the cart.*/
 
+void cartSetLastPosition(struct cart *cart, char *position, struct hash *oldVars);
+/* If position and oldVars are non-NULL, and oldVars' position is different, add it to the cart
+ * as lastPosition.  This is called by cartHtmlShell{,WithHead} but not other cart openers;
+ * it should be called after cartGetPosition or equivalent. */
+
 void cartTdbFetchMinMaxPixels(struct cart *theCart, struct trackDb *tdb,
                                 int defaultMin, int defaultMax, int defaultDefault,
                                 int *retMin, int *retMax, int *retDefault, int *retCurrent);
 /* Configure maximum track height for variable height tracks (e.g. wiggle, barchart)
  *      Initial height and limits may be defined in trackDb with the maxHeightPixels string,
  *      Or user requested limits are defined in the cart. */
 
 #endif /* CART_H */