본문 바로가기

WAS/Weblogic

[weblogic] 어플리케이션간 세션 공유 방법

기본적으로 웹 어플리케이션간에는 세션을 공유하지 않는다.

그러나 필요에 의해서 웹 어플리케이션에서 세션을 공유하고 싶다면

weblogic-application.xml 에 다음과 같은 세팅이 요구된다.

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<weblogic-applicaion xmlns="http://www.bea.com/ns/weblogic/90";;>

...

<session-descriptor>

<persistent-store-type>memory</persistent-store-type>

<sharing-enabled>true</sharing-enabled>

...

</session-descriptor>

...

</weblogic-application>

 

이렇게 application level 에서 설정하게 되면 web application level의 session description 은 무시된다.
 즉 applicaion level 이 우선이다.

sharing-enabled 가 true 일 경우 해당 application 내에 있는 모든 web application 은 부팅시 같은 session instance를 참조하여 시작된다.

 

[동일 도메인 URL 간 세션 공유하기]

kr.abc.com 과 en.abc.com 간의 세션을 공유하고 싶다면 weblogic.xml 에 다음의 session descriptor 를 추가한다.

단, 이 구성은 동일 웹로직 도메인내의 app 일 경우에 적용 되는 것이며. abc.com 과 같이 2개 이상의 이름이 동일해야 한다.

 

Specifies the domain for which the cookie is valid. For example, setting cookie-domain to.mydomain.com returns cookies to any server in the *.mydomain.com domain.

The domain name must have at least two components. Setting a name to *.com or *.net is not valid.

If not set, this attribute defaults to the server that issued the cookie.

For more information, see Cookie.setDomain() in the Servlet specification from Sun Microsystems.

 

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">

<!-- Insert session descriptor element here -->
<session-descriptor>
  <persistent-store-type>replicated_if_clustered</persistent-store-type>
  <sharing-enabled>true</sharing-enabled>
  <cookie-name>JSESSIONID</cookie-name>
  <cookie-domain>.abc.com</cookie-domain>
</session-descriptor>