function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Doug ACFDoug ACF 

Site Login Error after Browser Tab Close

We have a pretty typical Sites login page for a Customer Portal.  We are finding that if the user logs in successfully, closes just that one browser tab, opens a new tab, and then attempts to login again, they get one of those generic "An error has occurred loading a Visualforce page" errors.  If the user logs out first, or closes the browser entirely, they can login fine. 


Seems like something to do with the session cookie but not sure not to work around it.  Any suggestions?


Can you check if the user is already logged in (in Apex) before having them login?

Doug ACFDoug ACF

Hi Ryan -


Sure that seems like an ok workaround but I am not clear why it is happening.  We have a similar portal where is does not happen.  I would think that Site.Login() would just flush any existing session in the browser.


What is the best practice for checking if the user is logged in?  I don't see a specific method for that.  Should I just invoke a UserInfo.getSession and assume null=not logged in?


Doug, did you ever get this sorted out?