Skip to content

Commit 6b3b1b5

Browse files
committed
modifieid SampleWebView.cs to save/restore the session cookie.
1 parent 710d51c commit 6b3b1b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sample/Assets/Scripts/SampleWebView.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ IEnumerator Start()
5757
},
5858
ld: (msg) =>
5959
{
60+
#if UNITY_IPHONE
61+
PlayerPrefs.SetString("sessionCookie", webViewObject.GetSessionCookieFromServer());
62+
#endif
6063
Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
6164
#if UNITY_EDITOR_OSX || !UNITY_ANDROID
6265
// NOTE: depending on the situation, you might prefer
@@ -104,6 +107,12 @@ IEnumerator Start()
104107
},
105108
//ua: "custom user agent string",
106109
enableWKWebView: true);
110+
#if UNITY_IPHONE
111+
if (!string.IsNullOrEmpty(PlayerPrefs.GetString("sessionCookie", ""))) {
112+
webViewObject.SetSessionCookieFromClient(PlayerPrefs.GetString("sessionCookie", ""));
113+
}
114+
#endif
115+
107116
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
108117
webViewObject.bitmapRefreshCycle = 1;
109118
#endif

0 commit comments

Comments
 (0)