I store user data such as name, password and email in your HttpSession
with setAttribute
.
I want to know if it is safe to store critical data in HttpSession
.
I store user data such as name, password and email in your HttpSession
with setAttribute
.
I want to know if it is safe to store critical data in HttpSession
.
Try storing login information in one of the following user repositories (checking the validity while logging in):
It's not the full list of the authentication options.
You should at least use SSL/HTTPS for login and any other sensitive data.
Take a look at this article: http://en.wikipedia.org/wiki/Session_hijacking
And here is a nice SO discussion on that issue: What is the best way to prevent session hijacking?
Some security issues are also mentioned here: What should every programmer know about web development?
Ideal practice is to NEVER save passwords in any means of the application. Ideally passwords need to be saved encrypted in the DB's user table if you use db based authentication or use LDAP authentication.
After being successfully authenticated, you can keep the fields such as email and name in the http session. Its best that the username is kept (which is unique) in session and profile information has to be read from the database based on this username by performing a database read. can keep this information in a cookie to facilitate repopulating frequent visitors with some information as well.
most important thing is to NOT save passwords in hidden variables,cookies or query strings AT ALL.
any sensitive information that MUST be kept must be in a SESSION but encrypted.