I found that with the cookie setting at medium, this problem exists, even if I add our site to always allow cookies.
If I change the cookie setting to "allow all cookies from all sites", then it works properly and the login is ok.
It's unrealistic to force all users to completely open their system to "allow all cookies from all sites" as this can allow other sites to do harm.
This happens with or without the script code added from a previous message in this thread.
This is becomming a pretty obvious obsticle to our moving live and could really use some help resolving this issue.