# Generate or get unique ID from a web server and save that for the lifetime of the game :)

**URL:** <https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755>\
**Category:** Blueprint\
**Tags:** variables, httprequest, url, unreal-engine, Blueprint, CPP, question\
**Created:** [March 18, 2023, 5:54pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755 "2023-03-18T17:54:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnapsys](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cnapsys](https://forums.unrealengine.com/u/cnapsys)\
**Post date:** [March 18, 2023, 5:54pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/1 "2023-03-18T17:54:35Z")

</div>

Ok, so I’m still in the phase of tweaking and wrapping up my very first game.  
It’s coming along nicely and I literally couldn’t have done without you guys.  
Thanks again for all the help so far.

What I am trying to do next is a bit tricky and I have no clue where to start…

When a user starts the game I would like to do 1 of the following:

1. if there is an internet connection… request an id from a url (backend is in php)  
the php script will generate a uniqueID and send it back to the game. (Save this id locally, somewhere/somehow so that every time the user starts the game that is already set)

2. generate a uniqueID (following a specific pattern) locally, inside the game (save that somewhere/somehow) and post that to the server.

I really need this uniqueID so that I can save the user’s data on the server.

As always, any tips, pointers, suggestions (workarounds?) are greatly appreciated. Would prefer this to be done through BPs but if its only possible through cpp I’m open to that as well.

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [March 18, 2023, 6:00pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/2 "2023-03-18T18:00:45Z")

</div>

hi @cnapsys

Ive not used it personally but have you looked into this:

[VaRest in Code Plugins - UE Marketplace (unrealengine.com)](https://www.unrealengine.com/marketplace/en-US/product/varest-plugin/questions)

Then you need a basic webserver dealing with the request, that isnt my forte im afraid!

---

<div class="post-metadata">

**Author:** ![cnapsys](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cnapsys](https://forums.unrealengine.com/u/cnapsys)\
**Post date:** [March 18, 2023, 10:18pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/3 "2023-03-18T22:18:03Z")

</div>

Looks promising, but I can’t find any documentation or tutorials for it ☹

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [March 19, 2023, 8:44am UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/4 "2023-03-19T08:44:46Z")

</div>

A quick google will help

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/4/a94da82315bdc617a68e59498b593d56ce585c02.jpeg "Basic GET tutorial for VaREST plugin and Unreal Engine 4") ](https://www.youtube.com/watch?v=B90jnsEJ6E0)

---

<div class="post-metadata">

**Author:** ![cnapsys](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cnapsys](https://forums.unrealengine.com/u/cnapsys)\
**Post date:** [March 22, 2023, 10:17pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/5 "2023-03-22T22:17:38Z")

</div>

Thank you!  
I was able to make it work by connecting to the server… generating in php a unique token and getting that back to UE.  
Now… how can I save this token as a global config variable locally, so on any subsequent game launches I can read it from that variable???  
Is there a mode (higher level than the game instance) where I can set this variable kind of like a config variable??? That is persistent through quitting and restarting the game?  
Any tips are greatly appreciated.

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [March 22, 2023, 11:01pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/6 "2023-03-22T23:01:14Z")

</div>

you can store Variables permanently and persistant in your Custom GameInstance. The GameInstance gets initialized on GameStart and stays alive, even during level loads… it only gets destroyed when quitting the game.

---

<div class="post-metadata">

**Author:** ![cnapsys](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cnapsys](https://forums.unrealengine.com/u/cnapsys)\
**Post date:** [March 23, 2023, 8:25pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/7 "2023-03-23T20:25:29Z")

</div>

That’s the issue… I need to save a config variable that I can read every time the game starts.  
When the game starts for the 1st time, I can connect to my web server, generate a unique token which I can pass back to the game. I would like to be able to save that token, so on any future game sessions I can access it.

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [March 23, 2023, 8:36pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/8 "2023-03-23T20:36:59Z")

</div>

Therefor… take a look at the [SaveGame](https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/SaveGame/) Object.

Alternatively… use a free json/xml/txt read/write Plugin from the marketplace… or… if you are able to do so, write your own textfile writer/reader.

---

<div class="post-metadata">

**Author:** ![Raja.Haris](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/raja.haris/32/1191940_2.png) [@Raja.Haris](https://forums.unrealengine.com/u/Raja.Haris)\
**Post date:** [March 23, 2023, 8:40pm UTC](https://forums.unrealengine.com/t/generate-or-get-unique-id-from-a-web-server-and-save-that-for-the-lifetime-of-the-game/793755/9 "2023-03-23T20:40:32Z")

</div>

In CPP we have a class called **UDeveloperSettings** which we can use to have our own custom .ini fields.

I am afraid I don’t know the alternative for this in blueprints but you can use simple file handling to read and write the token file or just use the existing save game system.
