question

Yousif Ablahad avatar image
Yousif Ablahad asked

Preventing multiple login simultaneously

I know there are a lot of other threads about this but they all seem to be old at this point and not sure if anything has changed. Is there still no way to prevent multiple login? I have clients signing in using playfab then connecting to photon. I don't want it where people can use the same account in multiple places at the same time. Is there a way to prevent this? I know in one of the other threads you guys mentioned cloud scripting, is this still the only way?

Also, is there a feature to prevent users from purchasing same item twice? or will this have to be done in the clients device by checking and removing the items.

,

I know there are a lot of other threads about this but they all seem to be old at this point and not sure if anything has changed. Is there still no way to prevent multiple login? I have clients signing in using playfab then connecting to photon. I don't want it where people can use the same account in multiple places at the same time. Is there a way to prevent this? I know in one of the other threads you guys mentioned cloud scripting, is this still the only way?

Also, is there a feature to prevent users from purchasing same item twice? or will this have to be done in the clients device by checking and removing the items.

Account ManagementCloudScriptphotonPartner Add-ons
10 |1200

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

Hernando avatar image
Hernando answered

I believe you have searched for this thread: https://community.playfab.com/questions/382/206721757-How-to-prevent-duplicate-login-.html, and it is still an effective solution to prevent multiple login for now. Besides, as Brendan said, we will be adding session-based login tokens at a later date, at which point you'll be able to invalidate previous tokens for the account on a login. Please keep track on our blog website on: https://blog.playfab.com/blog and we'll be making sure to call this out in our News updates as soon as this is available.

For making an item purchased only once by a player, PlayFab does not provide this feature for now. we recommend that you filter the item out of the list of those shown to the player in the in-game interface, and not allow the player to purchase it via the client. But it should be noted that some hackers could still bypass this and purchase more than one item via HTTP Request tool like Postman.

1 comment
10 |1200

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

Good Guy avatar image Good Guy commented ·

That thread is from 2016 and here we are 4 years later.

0 Likes 0 ·
Jorge Mendez avatar image
Jorge Mendez answered

Hi, is this feature already shipped? Or is it still in WIP?

1 comment
10 |1200

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

Good Guy avatar image Good Guy commented ·

Yes, session tokens are in, but preventing multiple logins is on you to detect and invalidate the old session.

0 Likes 0 ·
Yash SIdhu avatar image
Yash SIdhu answered

I searched a lot to find a good solution but ended up making my own, here's the code... enjoy!

it's not guaranteed to work 100% of the time but should work mostly (in my case, all of the time) as it isnt common for randomly generated number to be same.

private void Awake() { DeviceId = UnityEngine.Random.Range(0, 99999); UpdateUserDataRequest request = new UpdateUserDataRequest(); request.Data = new Dictionary<string, string>() { { "ID", DeviceId.ToString()} }; PlayFabClientAPI.UpdateUserData(request, success => { Debug.Log("Successfully Updated Device id " + DeviceId); }, error => { Debug.LogError(error.GenerateErrorReport()); }); StartCoroutine(CheckPlayerID()); } IEnumerator CheckPlayerID() { yield return new WaitForSeconds(15); PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = AccountController.userID, Keys = null }, result => { if (result.Data["ID"].Value != DeviceId.ToString()) { StartCoroutine(AutoLogout()); ErrorGenerator.instance.GenerateError("Another device logged in, logging out in 4 seconds"); } }, (error) => { Debug.Log(error.GenerateErrorReport()); }); StartCoroutine(CheckPlayerID()); } IEnumerator AutoLogout() { yield return new WaitForSeconds(4); Logout(); }

,

I searched a lot to find a good solution but ended up making my own, here's the code... enjoy!

it's not guaranteed to work 100% of the time but should work mostly (in my case, all of the time) as it isnt common for randomly generated number to be same.

private void Awake() { DeviceId = UnityEngine.Random.Range(0, 99999); UpdateUserDataRequest request = new UpdateUserDataRequest(); request.Data = new Dictionary<string, string>() { { "ID", DeviceId.ToString()} }; PlayFabClientAPI.UpdateUserData(request, success => { Debug.Log("Successfully Updated Device id " + DeviceId); }, error => { Debug.LogError(error.GenerateErrorReport()); }); StartCoroutine(CheckPlayerID()); } IEnumerator CheckPlayerID() { yield return new WaitForSeconds(15); PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = AccountController.userID, Keys = null }, result => { if (result.Data["ID"].Value != DeviceId.ToString()) { StartCoroutine(AutoLogout()); ErrorGenerator.instance.GenerateError("Another device logged in, logging out in 4 seconds"); } }, (error) => { Debug.Log(error.GenerateErrorReport()); }); StartCoroutine(CheckPlayerID()); } IEnumerator AutoLogout() { yield return new WaitForSeconds(4); Logout(); }

1 comment
10 |1200

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

Mohamed Younes avatar image Mohamed Younes commented ·

In hope your game becomes successful and you get thousands or maybe millions or DAU, only then you'll know how wrong both approaches are once you get the playfab bill.it's not rocket since to send a request every x seconds, people asking for out of the box solution because the suggested solutions are wrong "Cost wise". you'll be surprised how huge the bill could get. This and other solutions suggested by playfab admin would work, but they are not realistic or real life applicable.

0 Likes 0 ·

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.