在Android应用程序登录后,如何在php api中创建令牌会话?
像这样:
我想确保当用户登录时,无论发生什么事情(崩溃,关机/关机/重启,离开应用程序),用户信息数据都将在所有活动中发送应用程序到Web服务器.
我只是使用:
session_start();
$_SESSION['username'] = $user;
$_SESSION['auth'] = "true";
Run Code Online (Sandbox Code Playgroud)
如果是这样,我如何将此会话传递到Android应用程序?
在Android应用中登录身份验证:
HttpClient client = new DefaultHttpClient();
String url = "http://www.somewebsite.com/login.php?username="+username+"&password="+password;
HttpGet request = new HttpGet(url);
// Get the response
ResponseHandler<String> responseHandler = new BasicResponseHandler();
response_str = client.execute(request, responseHandler);
php android authentication login session-cookies
Run Code Online (Sandbox Code Playgroud)