PHP sessions

I am creating a social app and I need to save the user in a session so that when they login/register to the app, they stay logged in until they log out. I can do that in PHP but how do I transfer the session to the Corona Front end side ?

When a user logs in, you can send a session id to the front end, and keep it in local database, in json file or in system preferences. Later, every time you need to get data from the server, you can send that session id and check the validity on the server side.

1 Like

You are essentially looking for JSON Web Tokens: https://en.wikipedia.org/wiki/JSON_Web_Token.

Simply echo the session id back to your app

Is it ok to use the username instead of id ?

Why not give the mobile-app user a token after login. Then whenever the mobile-app interacts with the server, it will send this token as authentication. When user logout from the mobile app, delete the token.

Maybe more like stateless connections.

1 Like