I'm building a mobile app using AngularJS as frontend, and SlimPHP as API provider that connects to Mysql. Frontend and backend are on separate domains.
- So an user posts the login form from Angular
- PHP catches it and authenticates the user and then generates a random token
- This token is then stored in database(user table) and passed back to Angular in Json format
- Angular stores the token in cookie.
So on every $http call from Angular to API, I want to embed the token in the header so PHP can verify again the DB user table if the call is legit.
I'm wondering if this a secure solution?