I already have CRUD web application which is build using Codeigniter PHP framework and Ion Auth authentication library (for Codeigniter). So users needs to log-in to use the site etc.
Now Im building small mobile app using Phonegap & jQuery mobile which uses this same backend. There is "REST like" api in backend which handles all ajax requests from mobile client.
How should I handle user authentication for this mobile app? I want to use as much as possible existing backend codebase.
Im planning something like this:
- From client send username & pass to server
- Return session id back to client from server
- Store session id to client (local store)
- Send that token in each requests to server and validate it in serverside.
How to do this in backend side? For login, I can use Codeigniter Ion Auth library login methods and get Codeigniter (PHP) session id. In second request when user send some actual data together with sessoin id, how to validate the session id? Or is it better idea to build completely new login functionality for mobile app authentication than try to use existing functionality (Codeignitre Ion Auth library)?
All ideas and suggestions are more than welcome!