Okay so, with that code I think we've managed to get the login working. The last issue would seem to be the cookies.

" Cookies are not enabled on your browser. Please adjust this in your security preferences before continuing. "