I am not a professional. Hope I can solve your problem.
I have two method to do the member system.
First, I will create a Data model like User.java
-> User.java
class User{
private String username = "";
private String password = "";
// Getter and Setter..
}
while a user is login, create a new user object.
User user = new User();
user.setPassword(...);
user.setUsername(...);
When you need to get information from server by httprequest. What you need to do is get the information from User object
Url url = new Url("http://your.server/index.php?username=" + user.getUsername() + "&password=" + user.getPassword());
HttpURLRequest conn = url.openConnection();
.......
Further information.
I usually save the cookie from the login process.
ArrayList<String> cookiesList = new ArrayList<String>();
Map<String, List<String>> mHeaderMap = mConnection.getHeaderFields();
String headername = "";
for(int i = 0; (headername = mConnection.getHeaderFieldKey(i)) != null; i++){
if(headername.equals("Set-Cookie")){
cookiesList.add(mConnection.getHeaderField(i));
}
}
Then if you send another login request. you use the cookie again and send to the server.
mConnection.setRequestProperty("Cookie", cookie);
More Information here.
On server side.
<?php
session_start();
if($_GET.count() > 0)
$username = $_GET['username'];
if($_GET.count() > 0)
$password = $_GET['password'];
$arr = array();
if($_SESSION['username'] == $username && $_SESSION['password'] == password){
$arr = array("isValid" => true, "message" => "");
}else{
$arr = array("isValid" => false, "message" => "");
}
echo json_encode($arr);
?>
On android
if(isValid){
startActicity(....)
}