Fixed clearing of session when changing api endpoint
[#59449300]