question

jfoose avatar image
jfoose asked

HTML5 authentication persistence

What is the best practice for persisting authentication in an HTML5 app? For example, in my app I am logging in via LoginWithEmail and storing the EntityTokenReponse in a cookie. Subsequent API calls after login work fine, but after the browser is refreshed the authentication state is lost in PlayFab(I see null values for properties in _internalSettings). What PlayFab interface(s) should I use to restore the auth state from the cookie values? Or am I missing some pieces here?

Thanks much

Authentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Hernando avatar image
Hernando answered

JavaScriptSDK does not support using cookies to store the player's authentication content, so the token will released from memory after closing tab. But there's nothing preventing you from doing it in your own client code, you could write custom logic to support as storing the authentication content in a cookie as you like.

Besides, in addition to storing the authentication content , don't forget checking the cookie and update _internalSettings before calling the login API of Playfab.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.