我通过soap webservices成功开发了一个带有mysql数据库的登录表单。我希望进行会话管理,但我无法开发。请帮帮我。
如果您需要编码部分,请参阅此link(我使用相同的代码登录表单):
我在这里做了以下修改。
谢谢
答案 0 :(得分:0)
You can use SharedPreferences like this: 1. Store username in SharedPreferences after successfully logging in. 2. Delete username from SharedPreferences after successful logout. 3. Override the next activity onResume() method and check for username from SharedPreferences. if (pref.getString("username") == null) { session expired; redirect to login activity. } **OR** Clear activity stack when doing logout operation. Intent intent = new Intent(this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);