Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
677 B

  1. import 'package:shared_preferences/shared_preferences.dart';
  2. const sessionCookieName = 'sessionCookie';
  3. void setSessionCookie(String cookie) async {
  4. final prefs = await SharedPreferences.getInstance();
  5. prefs.setString(sessionCookieName, cookie);
  6. }
  7. void unsetSessionCookie() async {
  8. final prefs = await SharedPreferences.getInstance();
  9. await prefs.remove(sessionCookieName);
  10. }
  11. Future<String> getSessionCookie() async {
  12. final prefs = await SharedPreferences.getInstance();
  13. String? sessionCookie = prefs.getString(sessionCookieName);
  14. if (sessionCookie == null) {
  15. throw Exception('No session cookie set');
  16. }
  17. return sessionCookie;
  18. }