I tried on my work computer, so it may be a problem here.
But, I do have another question.
I did read that if you try to call this code (the code you shared above) from a modal form, then it will not work. My login form is modal. When reading, it said that this can be overcome, but it did...