First working version. Global vars in rootScope and cookies. No ui-router.