Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

357
Vistas
Android and PHP: Check which user or users are currently logged in

I am currently working on a mobile application. I have created an online database and am able to establish connection to it with the app. The user can register and log in to this app, and this part of the app works perfectly. Also in this app, I allow users to book for classes, the problem I am running into is linking the classes information table with the user information table. I need to know the "user id" of the current logged on user so I can add this ID to the classes table.

Whats the easiest way to do that? I have read that Sessions would be helpful but i do not know how to start implementing it in my code. Any help would greatly be appreciated.

Side Note:

I used PHP files to login and register users, as well as establishing the connection. These files were uploaded to my online server, which the application can connect to and call the appropriate file according to the function. For example, when logging in, the app will call the login.php

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

you have to add a field in your user table, a bit, if it is turned on means if that bit is equal to 1 it means user is already login and if that bit is 0 then user is not already login, you can use Shared Preferences to check for the same app in which user is logged in.

over 4 years ago · Santiago Trujillo Denunciar

0

If user password is right then you should do the following in your php compare if password and user input are == to the stored in db then if are true

 <?php 
        if(session_id() == '') {

            session_start();
        } 
        if($user == $db_user) && ($password == $db_password)){ 
        $_SESSION["login"] = "1";
    } else {
$_SESSION["login"] = "0";
}

?>

php file to protect page to not be seen by others

<?php 
    if(session_id() == '') {

        session_start();
    } 

    if(isset($_SESSION["login"] == 1))){
    echo "user logged";

    } else {

    echo "invlaid user or password";
    }

?>
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda