Added a redirect to the main page if login successful and started session with cookie.