Answer the question
In order to leave comments, you need to log in
What is the best way to store users and balance in a database?
Hello!
What is the best way to store users and balance in a database?
The problem is this: on the site I use authorization through VK. If the authorization is successful, $_SESSION['userid'] contains the VK user ID (for example, $_SESSION['userid'] = 1), and the ID is also stored in the database. No encryption or hashing. It's just stupid in the database column "id" and user IDs in it.
Further, based on $_SESSION['userid'] it is determined whether it is authorized or not (for example, if(isset($_SESSION['userid'])) { show user panel } and so on with all elements and code that is available only to authorized users.
Bad whether it?
And another question about balance. Under the balance, I have a separate table, where there is a column with the same user ID (ID from VK), and a column with the balance itself. Again, not encrypted in any way.
Is it possible to leave everything like that? In fact, I don’t store the password, I don’t store any information other than the VK ID and full name.
Thank you to everyone who responds
Answer the question
In order to leave comments, you need to log in
The bad thing is that if I, for example, do not have a VK profile, then in principle I will never get to your site as a full-fledged user.
Are you a fan of VK?)
It's better to always link: User-ID in your system and to it - already link other accounts (third-party systems).
Balance - always bind to your User-ID and give the opportunity to enter WITHOUT VK.
So that, if the user loses access to VK (well, they locked his account there, for example), he can log into his account on your site and LINK his other (new) account to it and continue working on your service ...
(many letters happened...)
Everything is fine. But keep in mind that the VK profile can be deleted / forgotten. Those. there should be an alternative possibility of authorization.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question