From 14d3f5b1ddfd39f7866a3878f3fad6a40fcfc5a6 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Tue, 12 Mar 2024 17:52:54 -0700 Subject: [PATCH] Store session ID in SessionStorage instead of window.name We've been storing sessionID in window.name because of https://github.com/flet-dev/flet/issues/1629. However, `window.name` is not preserved in mobile Safari during OAuth session. It looks like Flutter has fixed that in launchUrl() (https://github.com/flutter/packages/blob/main/packages/url_launcher/url_launcher_web/lib/url_launcher_web.dart#L87) https://stackoverflow.com/a/73821739/1435891 --- packages/flet/lib/src/utils/session_store_web.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/flet/lib/src/utils/session_store_web.dart b/packages/flet/lib/src/utils/session_store_web.dart index fad3d0c02..d1624041f 100644 --- a/packages/flet/lib/src/utils/session_store_web.dart +++ b/packages/flet/lib/src/utils/session_store_web.dart @@ -3,18 +3,19 @@ import 'dart:html' as html; import 'package:flutter/foundation.dart'; +const String _sessionIdKey = "_flet_session_id"; + class SessionStore { static String? get sessionId { - return html.window.name; + return get(_sessionIdKey); } static set sessionId(String? value) { - html.window.name = value; + set(_sessionIdKey, value ?? ""); } static String? get(String name) { debugPrint("Get session storage $name"); - return html.window.sessionStorage[name]; }