• Advertisement
Sign in to follow this  

Question about logging people in

This topic is 2852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I have a game where I wish people to log in. I have it set up where it reads in a text file on start up and then caches it. Is there a better way of doing this?

Share this post


Link to post
Share on other sites
Advertisement
Is it a server? Does it have uptime requirements? How do you handle new users?

At the very least, if the program ever writes to the file it should do this in a robust manner to minimise the chances of the file becoming corrupted. For example, you could write to a temporary file, then use an atomic rename operation to replace the original file.

Another important aspect is security. Avoid keeping plaintext user passwords. Instead, store a hash of the user password, preferably using a "salt".

If the program is "serious", then the obvious way to go would be to move the user information into a database. A proper database will ensure there is no corruption of the data, and can be configured to handle high loads (e.g. multiple users creating accounts at the same time, while allowing others to log in). This also means that you can develop a separate user admin application quite easily, for example in a game you might want to handle ban requests.

At the end of the day though, the effort should be proportional to the size and scope of the project. If you have something working, you might find your time better spent making the rest of the program awesome, which may eventually drive in enough users to justify a more complex approach.

Share this post


Link to post
Share on other sites
Thanks for your reply.
It is a server. No uptime requirements. And currently new users are added in a very simple manner...packet uses a 'registering user' ID along with a name and pass and then checks this name against the current cache, and if it doesn't exist add it and write to text file.

I'll likely revisit this idea in the future when I have time to improve my login code.

Your input has been valuable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement