我是新来的。基本上,我在Web应用程序中使用代码Igniter框架。我为我的Web应用程序创建了REST API,在用户使用API登录后,所有方法都会检查session_id是否存在,然后继续进行,如果不存在,则给出
{ ['status'] = false, ['message'] = 'unauthorized access' }
Run Code Online (Sandbox Code Playgroud)
我正在使用flutter创建应用程序,当我使用flutter的http方法时,它将更改每个请求的会话。我的意思是,它不维护会话。我认为它每次都会破坏并创建新的连接。这是我用于API调用get和post请求的thr类方法。
class ApiCall {
static Map data;
static List keys;
static Future<Map> getData(url) async {
http.Response response = await http.get(url);
Map body = JSON.decode(response.body);
data = body;
return body;
}
static Future postData(url, data) async {
Map result;
http.Response response = await http.post(url, body: data).then((response) {
result = JSON.decode(response.body);
}).catchError((error) => print(error.toString()));
data = result;
keys = result.keys.toList();
return result;
}
Run Code Online (Sandbox Code Playgroud)
我想发出API请求,然后存储session_id,是否可以在服务器上维护会话,以便我可以自行管理Web应用程序上的身份验证?
flutter ×1