I have some issue with storing session details in my ios app. I created a webview app. Whenever i close the app after logging in, it logs me out and asks for credentials everytime. This is working fine for my android app. Any fix for this.
Session not saving in ios flutter webview app
You can store the session by calling below code:-
onLoadStop: (controller, url) async {
if (url == null) {
return;
}
final cookieManager = CookieManager.instance();
final expiresDate = DateTime.now()
.add(const Duration(hours: 24))
.millisecondsSinceEpoch;
List<Cookie> cookieList = await cookieManager.getCookies(url: url);
cookieList.where((cookie) => cookie.expiresDate == null).forEach(
(cookie) => cookieManager.setCookie(
url: url,
name: cookie.name,
value: cookie.value,
path: cookie.path ?? '/',
domain: cookie.domain,
expiresDate: expiresDate,
isSecure: cookie.isSecure,
isHttpOnly: cookie.isHttpOnly,
sameSite: cookie.sameSite,
),
);
}
You have to store session or cookies for web view using CookieManager and you can call this code when your url is loading is completed.
© 2022 - 2024 — McMap. All rights reserved.