I have designed a website in which I need to have access to user’s profile, so I have a user class that keeps the profile information of users, such as name,username,etc to avoid of retrieving them from database every time.
Whats the best way to access to this information from other classes?
My idea is to make them all static to access to the attributes using class’s name is there any other option?
The ideal solution is to store the user data within a
databaseand have your other classes retrieve said data via adata access object(DAO). Any alternatives to this will most likely clutter your existing architecture and create security holes.Store the user data in a user bean, keep the bean stored in the user’s session, and then upload the bean to a database for future access.