Storing login data
Hello everyone!
I am trying to build a simple school management system in console. Once a user login I want to store some of the data in order to avoid querying for that data again. What would be the best approach?
I thought of using static such as
But from what I read this approach is not good as multiple applications can mix up the information.
4 Replies
"Multiple applications" can't really mess with your information
But i wouldn't do it that way either way. You could just have a "currently logged in user" in your main code flow
aha, got it. Thanks
Sorry, just to clarify.
I would still store my User in the static in order to get info from anywhere. Do I follow it correctly?
that would work, of course if you only have one user, otherwise you can use dictionary with userId as key
Multiple applications (meaning other exe instances of console app) not have access to other instances so no worries of mixing up between apps. But if you are setting the Pet from different lines of code then that will be overridden
yep, that makes sense. thanks a lot