|
|
- import 'package:shared_preferences/shared_preferences.dart';
-
- const sessionCookieName = 'sessionCookie';
-
- void setSessionCookie(String cookie) async {
- final prefs = await SharedPreferences.getInstance();
- prefs.setString(sessionCookieName, cookie);
- }
-
- void unsetSessionCookie() async {
- final prefs = await SharedPreferences.getInstance();
- await prefs.remove(sessionCookieName);
- }
-
- Future<String> getSessionCookie() async {
- final prefs = await SharedPreferences.getInstance();
- String? sessionCookie = prefs.getString(sessionCookieName);
- if (sessionCookie == null) {
- throw Exception('No session cookie set');
- }
-
- return sessionCookie;
- }
|