I have some PHP script that logs in and returns a JSON array with a session ID if the login was successful.
In my app, I want to login at the front page and continue out through the app being logged in. I created a singleton class that holds a session ID (along with a few other fields) received from the JSON from the PHP page. This singleton object's field "session_id" gets checked depending on what the user does.
If the user wants to log out, then the session_id just gets set to null thus logging out.
I also use the HttpURLConnection library to POST the username/password when logging in.
Is this a decent enough approach for handling this situation?
Here are some things you should think about:
This will guarantee a bit more security and functionality than just clearing the session id on your app side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With