code: private void setLastOpenedGallery(CmsGallerySearchBean searchObject) {
  
          if ((searchObject.getGalleries() != null)
              && (searchObject.getGalleries().size() <= 1) // if the size is 0, the user has actively deselected the galleries, so we want to handle this case too
              && searchObject.haveGalleriesChanged()) {
              String galleryPath = searchObject.getGalleries().isEmpty() ? null : searchObject.getGalleries().get(0);
              CmsWorkplaceSettings settings = getWorkplaceSettings();
              if (searchObject.getGalleryMode() == GalleryMode.adeView) {
                  settings.setLastUsedGallery("" + GalleryMode.adeView, galleryPath);
              } else {
                  String referencePath = searchObject.getReferencePath();
  
                  String referenceTypeName = "";
  
                  try {
                      CmsObject cms = getCmsObject();
                      CmsResource referenceResource = cms.readResource(referencePath);
                      I_CmsResourceType referenceType = OpenCms.getResourceManager().getResourceType(referenceResource);
                      referenceTypeName = referenceType.getTypeName();
                  } catch (CmsException e) {
                      LOG.error(e.getLocalizedMessage(), e);
                  }
                  settings.setLastUsedGallery(
                      CmsGallerySearchBean.getGalleryStorageKey(
                          searchObject.getGalleryStoragePrefix(),
                          referenceTypeName),
                      galleryPath);
              }
          }
      }
docs: Sets the last opened gallery information for the current user.<p>
  
  @param searchObject the current search