留言板

Keep a session variable after login which is set before user login

Abutalib Shaikh,修改在7 年前。

Keep a session variable after login which is set before user login

Junior Member 帖子: 36 加入日期: 16-5-17 最近的帖子
Hello everyone ,
I need to keep session variable after and before login within all portlets
I have following scenario.
1. when user select option from navigation portlet and set selected option variable value in session
which is accessible in all portlets
code : PortletSession session = request.getPortletSession();
session.setAttribute("select_option","ABC",PortletSession.APPLICATION_SCOPE);

and trying to access after user login by using below code :
<%
PortletSession pre=renderRequest.getPortletSession();
String product_name = (String)pre.getAttribute("select_option ", PortletSession.APPLICATION_SCOPE);
%>

and put entry in liferay-portlet.xml entry in both portlets :
<private-session-attributes>false</private-session-attributes>

but i am getting product_name=NULL after login
-seems Session is changed after login that's why we can't access session variable after login which is set before login.

- so please suggest me any way to achieve this requirement ?

thank you
thumbnail
Samuel Kong,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
You can set the follow property to 'false'. However, please be aware that there is a security risk with making this change. Consider your environment carefully before making the change.

    #
    # Set this to true to invalidate the session when a user logs into the
    # portal. This helps prevent phishing. Set this to false if you need the
    # guest user and the authenticated user to have the same session.
    #
    session.enable.phishing.protection=true
Abutalib Shaikh,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Junior Member 帖子: 36 加入日期: 16-5-17 最近的帖子
Thank's , Samuel emoticon

its working For me i am able to access session variable after login but ,
when click on logout getting same issue can't access session variable value in portlet after logout

i am not aware explain me what are the security ricks with this change .
can you please explain me the same ?
thumbnail
Sandeep Nair,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子
Why would you ever want to do that? When you logout, session is invalidated and new session is started. Obviously you would not get whatever you have stored in session. The whole meaning of having a session is so that servlet container uniquely identifies a user and storing something between login and logout.
thumbnail
Samuel Kong,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
thumbnail
Samuel Kong,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
when click on logout getting same issue can't access session variable value in portlet after logout

This isn't supported and you shouldn't even try to make this work. Huge security issues with this.
Abutalib Shaikh,修改在7 年前。

RE: Keep a session variable after login which is set before user login

Junior Member 帖子: 36 加入日期: 16-5-17 最近的帖子
Thank's , Samuel emoticon
for make very clear what are the security reasons , so
i am not going with session concept.

but ,

could you please suggest another way to achieve my requirement .
Requirement :
- i have one navigation (docbar same for all pages) which contains product list like "abc","xyz" etc
- when user select any product from navigation i want to maintain selected product value in whole website doesn't matters user logged in or not
- because my all page (portlets) content depends on selected "product".

- could you please help me for the same . . emoticon