It will be better if you can do this in the server side language itself. You will be validating the user credentials using a server side language and if that evaluates to success then you can redirect the page to a new one from there itself. No need to do this in javascript.