8c0ef9e7b8633c0994cdaf8030d9c49c8b402016
max
  Sat Sep 26 21:53:54 2026 -0700
cart/hgSession: fix the session-load notice to always name the session actually loaded

diff --git src/hg/hgSession/hgSession.c src/hg/hgSession/hgSession.c
index 86f6b239a04..bed7f0cb928 100644
--- src/hg/hgSession/hgSession.c
+++ src/hg/hgSession/hgSession.c
@@ -958,30 +958,35 @@
 sqlDyStringPrintf(dy, "DELETE FROM %s WHERE userName = '%s' AND "
                   "sessionName = '%s';",
                   namedSessionTable, encUserName, encSessionName);
 sqlUpdate(conn, dy->string);
 
 dyStringClear(dy);
 sqlDyStringPrintf(dy, "INSERT INTO %s ", namedSessionTable);
 sqlDyStringPrintf(dy, "(userName, sessionName, contents, shared, "
                "firstUse, lastUse, useCount");
 if (gotSettings)
     sqlDyStringPrintf(dy, ", settings");
 sqlDyStringPrintf(dy, ") VALUES (");
 sqlDyStringPrintf(dy, "'%s', '%s', ", encUserName, encSessionName);
 sqlDyStringPrintf(dy, "'");
 cleanHgSessionFromCart(cart);
+/* A pending "session just loaded" marker (and the name/owner it refers to) belongs to the
+ * live cart's next page view, not to a session's own saved contents. */
+cartRemove(cart, hgsSessionJustLoaded);
+cartRemove(cart, hgsOtherUserSessionName);
+cartRemove(cart, hgsOtherUserName);
 struct dyString *encoded = dyStringNew(4096);
 cartEncodeState(cart, encoded);
 
 // First output the hubStatus id's for attached trackHubs
 outAttachedHubUrls(cart, encoded);
 
 // Now add all the default visibilities to output.
 outDefaultTracks(cart, encoded);
 
 sqlDyAppendEscaped(dy, encoded->string);
 dyStringFree(&encoded);
 sqlDyStringPrintf(dy, "', ");
 sqlDyStringPrintf(dy, "%d, ", sharingLevel);
 if (firstUse)
     sqlDyStringPrintf(dy, "'%s', ", firstUse);