Unity Web Player Account System

I want to create a game on web platform. The game is not multiplayer, so there is no need to any server. But I want save player data for each player and I want them loggined to my game. I am not sure about how to do that. Is this following pattern is good?

  1. In Assets/Resources folder, create a text file (called users.txt in this case) which contains player username password …etc. Read this file on start then compare player username and password with them if it matches one of them, then player can be logged in.
  2. After game play, save player data to a file by serializing player data with a consistent file name, after player relogged in, load this file.

Now. I know first method is not look safe but I want to know is this file (user.txt) a shared single file for each client. Do I need to check for the file if is in use…etc. When hundreds of users attempting to open the game via browser, are many file read operation occuring on one single file? How this process working? Can I find a technical guide or documantation for this process.

Thanks in advance and sorry for my bad English.

Shor answer:

Have a server or is better forget to use web or authentication

Long answer:

You can’t simple keep changing the users.txt file in resource because every change will need a new build and deploy of binaries. Futher, your players will need to download/update the game each time.

You can remotly download the txt file from a server, but is hack it a kid stuff, even encripted, because the decript code (and its key) is running in client side. The best aproeach is auth in external server.

For persistent storage you can’t write to files in web container.

Your only storage places are external servers, cookies and html5 sotrage data (HTML Web Storage API).

Even with external server you can have some problem to access different domain.

Because you didn’t access files directly how the server/browser manager its access and paralelism is not your concern. But its very documented in any library, database or operational system that you woul desire to use.