フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Ingemar Jansson
[SOLVED] Setting session attribute in auto login hook
2010/06/16 1:42
答え

Ingemar Jansson

ランク: New Member

投稿: 4

参加年月日: 2010/05/23

最近の投稿

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
2010/06/15 23:35
答え

Thomas Berg

ランク: Regular Member

投稿: 119

参加年月日: 2009/09/07

最近の投稿

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
2010/06/16 1:42
答え

Ingemar Jansson

ランク: New Member

投稿: 4

参加年月日: 2010/05/23

最近の投稿

Hej Thomas

Thank you.

Regards
Ingemar
Gary Pinkham
RE: [SOLVED] Setting session attribute in auto login hook
2010/08/05 5:59
答え

Gary Pinkham

ランク: New Member

投稿: 17

参加年月日: 2010/07/30

最近の投稿

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
2012/11/15 11:46
答え

Davy Kamerbeek

ランク: New Member

投稿: 23

参加年月日: 2012/03/12

最近の投稿

I'm having the same issue.. Can somebody give some pointers?
Davy Kamerbeek
RE: Setting session attribute in auto login hook
2012/11/17 0:47
答え

Davy Kamerbeek

ランク: New Member

投稿: 23

参加年月日: 2012/03/12

最近の投稿

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
2014/03/13 8:37
答え

vincent alfandari

ランク: New Member

投稿: 1

参加年月日: 2012/05/22

最近の投稿

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)