moved redirect after login to javascript from php