简体   繁体   中英

Session Attributes using spring security

Could anyone help me?

How can add session attributes if i am using spring security?

Let me explain:

When an user is logged, I want to create an object called Filters and other called Site

The aim of Filters object is to keep the different filters that the user can apply in a table.

The aim of Site object is to keep the site or place where the user works, to determine the info that can see in accordance of the Site.

I tried to create private objects variables in the main controller, but when multiple user are logged, they share the variables

Thanks

See this link .

If you what to use HttpSession to store this information, you should get the user identity first in your Controller and use it as key when you store in the session(Concat information when key exist in the session). For example You can use this link .

I tried to create private objects variables in the main controller, but when multiple user are logged, they share the variables

For the above issue, I would recommend you to put session attribute detail with the key as user_id which is unique for each user so once the user is logged in you can get the details (session attribute value) with user id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM