0

I have a (browser based) web application. On each page, I want to have a little label and link in a corner that displays the user's username and other account information along with a logout button. The information that will be displayed is immutable.

Should I store that account information in session attributes when a user logs in and forget about it or should I use a filter/interceptor and load it on each request in the request attributes?

  • What would the effect of logging out be, if the information is only stored in the request? – user40980 Jul 10 '13 at 15:43
  • @MichaelT I wasn't clear about that. For authentication, I only store the account id in the session. Then on each request that needs your account details, I retrieve all of them (account entity). The label only needs some of that info. – Sotirios Delimanolis Jul 10 '13 at 15:44
1

I would use a Session, as the information is sensitive. So the information displayed in your case would be (Account Information and UserName.) If it was only the UserName I would have thought of Request Scope, but since it is Account Information (Assuming Account numbers, etc) I would go for a session. Once the session is out, the user needs to log in again.

Or I would not display anything but the userName and the logout button.

1

You could do both,

If your application is big, and you choose to load the user's account info and display it on the page, it will cost you an sql query per page, which is an overhead.

To escape the overhead of making same sql query per page, use sessions!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.