Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ingemar Jansson
[SOLVED] Setting session attribute in auto login hook
June 16, 2010 1:42 AM
Answer

Ingemar Jansson

Rank: New Member

Posts: 4

Join Date: May 23, 2010

Recent Posts

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
Thomas Berg
RE: Setting session attribute in auto login hook
June 15, 2010 11:35 PM
Answer

Thomas Berg

Rank: Regular Member

Posts: 134

Join Date: September 7, 2009

Recent Posts

Hej Ingemar,

It's possible, check these settings in portal(-ext).properties:

 1##
 2## Request
 3##
 4
 5    #
 6    # Portlets that have been configured to use private request attributes in
 7    # liferay-portlet.xml may still want to share some request attributes. This
 8    # property allows you to configure which request attributes will be shared.
 9    # Set a comma delimited list of attribute names that will be shared when the
10    # attribute name starts with one of the specified attribute names. For
11    # example, if you set the value to "hello_,world_", then all attribute names
12    # that start with "hello_" or "world_" will be shared.
13    #
14    request.shared.attributes=LIFERAY_SHARED_
15
16##
17## Session
18##
19
20    #
21    # Portlets that have been configured to use private session attributes in
22    # liferay-portlet.xml may still want to share some session attributes. This
23    # property allows you to configure which session attributes will be shared.
24    # Set a comma delimited list of attribute names that will be shared when the
25    # attribute name starts with one of the specified attribute names. For
26    # example, if you set the value to "hello_,world_", then all attribute names
27    # that start with "hello_" or "world_" will be shared.
28    #
29    # Note that this property is used to specify the sharing of session
30    # attributes from the portal to the portlet. This is not used to specify
31    # session sharing between portlet WARs or from the portlet to the portal.
32    #
33    session.shared.attributes=org.apache.struts.action.LOCALE,COMPANY_,USER_,LIFERAY_SHARED_


HTH

Thomas
Ingemar Jansson
RE: Setting session attribute in auto login hook
June 16, 2010 1:42 AM
Answer

Ingemar Jansson

Rank: New Member

Posts: 4

Join Date: May 23, 2010

Recent Posts

Hej Thomas

Thank you.

Regards
Ingemar
Gary Pinkham
RE: [SOLVED] Setting session attribute in auto login hook
August 5, 2010 5:59 AM
Answer

Gary Pinkham

Rank: New Member

Posts: 17

Join Date: July 30, 2010

Recent Posts

Ingemar 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
RE: Setting session attribute in auto login hook
November 15, 2012 11:46 AM
Answer

Davy Kamerbeek

Rank: New Member

Posts: 23

Join Date: March 12, 2012

Recent Posts

I'm having the same issue.. Can somebody give some pointers?
Davy Kamerbeek
RE: Setting session attribute in auto login hook
November 17, 2012 12:47 AM
Answer

Davy Kamerbeek

Rank: New Member

Posts: 23

Join Date: March 12, 2012

Recent Posts

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.
vincent alfandari
RE: Setting session attribute in auto login hook
March 13, 2014 8:37 AM
Answer

vincent alfandari

Rank: New Member

Posts: 6

Join Date: May 22, 2012

Recent Posts

If you need to retrieve a variable such as a token SSO you can do this :
- In the hook AutoLogin set a request parameter :
1
2request.setParameter("tokenSSO", tokenSSO)

- Add a hook at event "login.events.post" that retrieve the request parameter and put it in the session
1
2String tokenSSO = request.getParameter("tokenSSO")
3request.getSession().addAttribute("tokenSSO", tokenSSO)
Menno Avegaart
RE: Setting session attribute in auto login hook
April 1, 2015 1:47 AM
Answer

Menno Avegaart

Rank: New Member

Posts: 1

Join Date: October 16, 2012

Recent Posts

HttpServletRequest doesn't have a setParameter method, so how did you really do this?
David H Nebinger
RE: [SOLVED] Setting session attribute in auto login hook
April 1, 2015 6:59 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 9226

Join Date: September 1, 2006

Recent Posts

Liferay wraps the incoming HttpServletRequest with it's own class that allows for parameter setting.