implement MainCtrl to handle sessions in angular