Foren
[SOLVED] Setting session attribute in auto login hook
Ingemar Jansson, geändert vor 13 Jahren.
[SOLVED] Setting session attribute in auto login hook
New Member Beiträge: 4 Beitrittsdatum: 24.05.10 Neueste Beiträge
Hi
I have set an attribute in the HttpSession in an auto login hook.
Then I set the request attribute AutoLogin.AUTO_LOGIN_REDIRECT.
When I try to get the attribute from the session it's not there.
I see in the code that there is a redirect when AutoLogin.AUTO_LOGIN_REDIRECT attribute is set but I thought the JSESSIONID cookie should keep the same session even after a redirect.
Is it not possible to set a session attribute in an auto login hook and fetch it from the page I'm redirecting to?
Regards
Ingemar
I have set an attribute in the HttpSession in an auto login hook.
Then I set the request attribute AutoLogin.AUTO_LOGIN_REDIRECT.
When I try to get the attribute from the session it's not there.
I see in the code that there is a redirect when AutoLogin.AUTO_LOGIN_REDIRECT attribute is set but I thought the JSESSIONID cookie should keep the same session even after a redirect.
Is it not possible to set a session attribute in an auto login hook and fetch it from the page I'm redirecting to?
Regards
Ingemar
Thomas Berg, geändert vor 13 Jahren.
RE: Setting session attribute in auto login hook
Regular Member Beiträge: 131 Beitrittsdatum: 07.09.09 Neueste Beiträge
Hej Ingemar,
It's possible, check these settings in portal(-ext).properties:
HTH
Thomas
It's possible, check these settings in portal(-ext).properties:
##
## Request
##
#
# Portlets that have been configured to use private request attributes in
# liferay-portlet.xml may still want to share some request attributes. This
# property allows you to configure which request attributes will be shared.
# Set a comma delimited list of attribute names that will be shared when the
# attribute name starts with one of the specified attribute names. For
# example, if you set the value to "hello_,world_", then all attribute names
# that start with "hello_" or "world_" will be shared.
#
request.shared.attributes=LIFERAY_SHARED_
##
## Session
##
#
# Portlets that have been configured to use private session attributes in
# liferay-portlet.xml may still want to share some session attributes. This
# property allows you to configure which session attributes will be shared.
# Set a comma delimited list of attribute names that will be shared when the
# attribute name starts with one of the specified attribute names. For
# example, if you set the value to "hello_,world_", then all attribute names
# that start with "hello_" or "world_" will be shared.
#
# Note that this property is used to specify the sharing of session
# attributes from the portal to the portlet. This is not used to specify
# session sharing between portlet WARs or from the portlet to the portal.
#
session.shared.attributes=org.apache.struts.action.LOCALE,COMPANY_,USER_,LIFERAY_SHARED_
HTH
Thomas
Ingemar Jansson, geändert vor 13 Jahren.
RE: Setting session attribute in auto login hook
New Member Beiträge: 4 Beitrittsdatum: 24.05.10 Neueste Beiträge
Hej Thomas
Thank you.
Regards
Ingemar
Thank you.
Regards
Ingemar
Gary Pinkham, geändert vor 13 Jahren.
RE: [SOLVED] Setting session attribute in auto login hook
New Member Beiträge: 17 Beitrittsdatum: 30.07.10 Neueste BeiträgeIngemar Jansson:
I have set an attribute in the HttpSession in an auto login hook.
Curious.. Is Auto Login Hook the same as "Custom Authentication"? as described here: Developing a custom authentication system
I can't seem to figure out how to get access to the HttpSession from within the Authenticator..
Thanks!
Gary
Davy Kamerbeek, geändert vor 11 Jahren.
RE: Setting session attribute in auto login hook
New Member Beiträge: 23 Beitrittsdatum: 12.03.12 Neueste Beiträge
I'm having the same issue.. Can somebody give some pointers?
Davy Kamerbeek, geändert vor 11 Jahren.
RE: Setting session attribute in auto login hook
New Member Beiträge: 23 Beitrittsdatum: 12.03.12 Neueste Beiträge
Ok, figured it out. The autologin has it's own HttpSession. When the user is logged in a new HttpSession is created.
So when you want to set some http session objects, you must set those objects after the autologin. So use a custom PostLoginAction that does that.
So when you want to set some http session objects, you must set those objects after the autologin. So use a custom PostLoginAction that does that.
vincent alfandari, geändert vor 10 Jahren.
RE: Setting session attribute in auto login hook
New Member Beiträge: 7 Beitrittsdatum: 22.05.12 Neueste Beiträge
If you need to retrieve a variable such as a token SSO you can do this :
- In the hook AutoLogin set a request parameter :
- Add a hook at event "login.events.post" that retrieve the request parameter and put it in the session
- In the hook AutoLogin set a request parameter :
request.setParameter("tokenSSO", tokenSSO)
- Add a hook at event "login.events.post" that retrieve the request parameter and put it in the session
String tokenSSO = request.getParameter("tokenSSO")
request.getSession().addAttribute("tokenSSO", tokenSSO)
Menno Avegaart, geändert vor 9 Jahren.
RE: Setting session attribute in auto login hook
New Member Beitrag: 1 Beitrittsdatum: 16.10.12 Neueste Beiträge
HttpServletRequest doesn't have a setParameter method, so how did you really do this?
David H Nebinger, geändert vor 9 Jahren.
RE: [SOLVED] Setting session attribute in auto login hook
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Liferay wraps the incoming HttpServletRequest with it's own class that allows for parameter setting.
Nithin KV, geändert vor 7 Jahren.
RE: [SOLVED] Setting session attribute in auto login hook
Junior Member Beiträge: 56 Beitrittsdatum: 23.07.12 Neueste Beiträge
Hi, Pls let me know How do you achieve this ? which class can wrap httpservlet request and set parameter ?
Kowbathullah Gnaniyar, geändert vor 7 Jahren.
RE: [SOLVED] Setting session attribute in auto login hook
Liferay Master Beiträge: 722 Beitrittsdatum: 19.12.07 Neueste BeiträgeNithin KV:
Hi, Pls let me know How do you achieve this ? which class can wrap httpservlet request and set parameter ?
Nithin,
To get the Session object between two hooks , you can try this in liferay 6.1
1. Set this property in portal-ext.properties
#
# Set a comma delimited list of attribute names that will be copied to the
# new session when the property "session.enable.phishing.protection" is set
# to true. Also if you set the value to "START_", "END_", then all attribute names
# that start with "START_" or "END_" will be shared between hooks.
#
session.phishing.protected.attributes=START_TIME
2. Setting the session in Hook-1
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
request.getSession(true).setAttribute("START_TIME", "something");
3. Receiving session object in Hook-2 passing from Hook-1
String sessionFromHook1= (String)request.getSession().getAttribute("START_TIME");
Hope this helps.
Nithin KV, geändert vor 7 Jahren.
RE: [SOLVED] Setting session attribute in auto login hook
Junior Member Beiträge: 56 Beitrittsdatum: 23.07.12 Neueste Beiträge
Thanks Zubair. it worked!!