Maybe more details are necessary to avoid possible confusion
over the process and other factors involved in your situation..?
The gmail login is being used as Safari web-mail?
Or have you an Apple Mail login with Gmail?
Should issue arrive by use of browser login, maybe try Brave.
However because their security goes a different route, and is
superior to other login web browsers, Brave may have issues.
Any issues with Safari browser in macOS or iOS should be
reported to Feedback at Apple. Product Feedback - Apple
To open link from webmail and go to other content online,
could cause secondary problem, due to conflicts in security.
(Sometimes Brave 'shields UP -or- Down' cannot connect.)
My use of three browsers: Safari, Firefox, & Brave; cover ground.
Safari continues to handle 'secure' sites + bookmarks: Issues.
Newer Firefox browser implements various improved features.
~ Older macOS end up with 'ESR Firefox builds' to get by.
While as webmail browser, for most secure sites, Safari can
be great; as it handles (from experience) passwords to a few
in much better ways. Other aspects of Safari aren't so good.
With older Macs, and more secure modern browsers, a choice
to use webmail seems to work better than older Apple mail.
And doesn't involve saving those histories in the macOS.
Your mileage and routes ~ may vary considerably.