changes the state of logout fuctions and redirected to index page after logout.