Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!