Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:25:27+00:00 2026-05-27T20:25:27+00:00

For databases that don’t require any sort of username or password, I normally fetch

  • 0

For databases that don’t require any sort of username or password, I normally fetch data from a MySQL db from my Android app by accessing PHP scripts. To send data to the database I send GET or POST variables to PHP scripts.

But if I need to access a database that would normally require a web user to login first, how would I interact with the database? In my Android app, the user would specify his login and password.

PHP Sessions?

Can Android apps somehow use PHP sessions when accessing PHP scripts on some web server via HTTP requests?

Send Login/Password as GET/POST params?

In my app, when accessing my PHP scripts, do I send the login and password as GET/POST parameters every time I want to access restricted data? Seems kinda sketchy sending login/password as GET/POST every time.

Auth token?

Or would I send the login/password once to authenticate and then retrieve some sort of token that I would send on subsequent calls to the PHP script? I would envision it working like this:

  1. User sends login info to PHP script
  2. After authentication is successful, random token is generated and placed in user table.
  3. Token is sent back to app
  4. Subsequent database calls include the token as a GET/POST parameter.
  5. PHP script uses token to authenticate user and fetch database info that is restricted to that user.

A couple things about this approach:

  1. When does the app log the user out? When he exits the app? When he switches to a different app? When the activity is destroyed?
  2. If the user does not manually log out of the app (which would normally clear the token value from the user table), when does the token value get cleared?
  3. What happens if the user shuts off his phone and looses connection to the database? Should the database automatically clear the token value from the user table after some period of time so that some random lucky individual couldn’t guess the token?
  4. Should the token also set some sort of last_accessed_at timestamp and deny authentication using the token after a certain period of time?

There are dozens of tutorials out there for accessing MySQL web databases using Android apps, but I can’t find any that discuss working with credentials and/or authentication schemes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:25:28+00:00Added an answer on May 27, 2026 at 8:25 pm

    Remember that sessions are normally tracked using a cookie. All you would have to do is save that cookie and use it in your headers when making requests from your android app, and then you have a working session.

    Also look into doing a special handshake or using some special kind of security. Never trust the input!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

More specifically, are there any databases that don't require secondary storage (e.g. HDD) to
I'm trying to figure out how to insert/update data into offsite databases that don't
I cant create mysql databases in phpmyadmi. It says that i don't have privileges.
How can I get a list of all the MySQL databases that exist on
Are there any ways to determine what the differences in databases are that affect
Currently we have 2 databases that we are going to use. One comes from
Is there any performance hit from querying over two (or more) databases on the
Is there an open-source Java library that adds XA support to databases that don't
I have an application that needs to join tables from multiple databases into a
We have 18 databases that should have identical schemas, but don't. In certain scenarios,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.