added login functions as prevent early clossing, warnings and reload page