Well, taking out the conditionals and the login form and simply using <div> tags solved the problem, at least so far. Now I’ve put back in a couple of conditionals in a different way, and the login form, and it seems to be working. So it might have been a cookie problem.
Thanks.