0
I’m creating an android app, where when run asks login and user
The android checks login and password in a web service made in php
Till then all is well that all is going well . but when I ask for information to the database performing a select in php in web service again it returns to me all data of the data group and not only of the logged-in user.
I believe that when I check the login I have to store the company code via (Session) and use it in the other php page for when use select with Session it returns only the user data
PHP code
<php
SESSION_START();
mysql_connect('localhost','','');
mysql_select_db('bd') or die (mysql_error());
$username = $_GET['a'];
$password = $_GET['d'];
$result = mysql_query("SELECT * FROM Tab_Config where Login='$username' and Senha='$password'");
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($result)>0)
{
echo $row['Cod_Empresa'];
$_SESSION['Cod_Empresa'] = $row['Cod_Empresa'];
}
else{
echo "";
}
mysql_close();
?>
Have you tried using Sharedpreferences on android? After you make the query, you can save there, in the other requests, you check if you have something saved and send as parameter. here is an example of how to use: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
– Geferson
I think you should save SESION_ID in the app, because to use the same session, you will need to send this ID via GET in your requests. Check this link: http://php.net/manual/en/function.session-start.php
– Jhonny Mesquita