The display of the site context menu is handled by comp/widgets/site_context/site_context.mc. The list of all sites is stored in and read from the Bric::App::Cache object ($c). The list of sites to which the user has permission to see is stored in the session, and read via get_state_data() and stored via set_state_data() (defined in Bric::App::Session). The currently-selected site, or "site context", is also stored in the Bric::App::Cache object, accessible via calls to get_user_cx() and set_user_cx(). The cache is stored in shared memory, so should only get flushed when the server restarts. Otherwise, the only reason I can think of that the site context is forgotten is if set_user_cx() is called for some reason.
Anyway, You'll want to put some debugging into comp/widgets/site_context/site_context.mc. If you use print STDERR statements, you can tail the bricolage error log to see the output. That’s how I've typically done my Bricolage debugging.