Search Unity

Client id and XAMPP database id

Discussion in 'Netcode for GameObjects' started by user321123321, Mar 4, 2023.

  1. user321123321

    user321123321

    Joined:
    Aug 14, 2021
    Posts:
    2
    Hello, im trying to learn some PHP and netcode at the same time, ive made simple database with user id username password and email, i have login and register scene, my question is, how can i bind user id from my database and client id in netcode as one? so that when i connect to session in game my client id on unity is downloading the id from database is it even possible? are there any better solutions?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    Netcode client ids are volatile, they cannot be used to identify a specific user. Nor should you need to know about the client id in your database since you already have the user identified via login. If you want to display that user‘s name to other clients, put that in a NetworkVariable since that information is temporary for the duration of the game session. You dont‘t want other clients to look that info up in your database.

    Note: at this point even for „tests“ you better implement all common best practices (ie password hashing with salt) when it comes to account security otherwise, sooner than later, someone is going to take over your database, get user info from it, and so on.
     
  3. user321123321

    user321123321

    Joined:
    Aug 14, 2021
    Posts:
    2
    thanks for the response, yeah that makes sense, im trying to make it as secure as possible so your opinion matters much to me, unfortunetly ive yet to use network variables, as i was focusing on having everything in my database, could you help me with that a bit? should i have my network variables script tied to my player, and have this script connected to my database?, right now the only connection with my database and ingame server is the login scene, after that i dont store anything locally on the server
     
  4. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440