?
Solved

change domain of JSESSIONID cookie in Apache

Posted on 2013-12-18
8
Medium Priority
?
2,175 Views
Last Modified: 2014-02-01
Currently JSESSIONID is set by xxx.domain.com and I'd like to read the JSESSIONID from yyy.domain.com, so how can I change the JSESSIONID cookie's domain from xxx.domain.com to .domain.com? I'm using Apache as web server. Thanks.
0
Comment
Question by:xiaoyunwu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39727536
You can do that by using ".domain.com" as the domain when you set the cookie.  Apparently there is an XML file somewhere that sets all the cookie parameters.  WEB-INF/web.xml?
0
 

Author Comment

by:xiaoyunwu
ID: 39727851
I can't find in WEB-INF/web.xml
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39728042
JSESSIONID is not going to be set by Apache but by Java.  Please click on "Request Attention" and get the JAVA Topic Area added to your question so the Java experts will see your question.  It would also help if you would post the exact program versions and methods you are using since there may be more than one way of doing this.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Accepted Solution

by:
xiaoyunwu earned 0 total points
ID: 39729695
I tried two options
1)
<IfModule headers_module>
Header edit Set-Cookie "^(JSESSIONID.*);.*$" "$1; path=/; domain=theeducationcenter.com"
</IfModule>

The problem with this approach is I can't match zzz.domain.com, if I only want to have domain reset when xxx.domain.com and yyy.domain.com not zzz.domain.com

2)
RewriteCond %{HTTP_COOKIE} JSESSIONID=(.*) [NC]
RewriteRule .* - [CO=JSESSIONID:%1:.theeducationcenter.com]

The same thing, I can't find out how to match domain in RewriteCond to say not when domain is zzz.domain.com

Another problem with second approach is that it will create another JSESSIONID at domain.com instead of overwrite JESSIONID at xxx.domain.com, so I end up with two JESSIONID cookies

Thanks.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 39730969
Are you using Tomcat (behind Apache) to host the application? Do you have access to modify the web application?

If so, you can add a file "META-INF/context.xml" that contains the below... (note: in your project, META-INF should be in the same directory as your WEB-INF)
<?xml version="1.0" encoding="UTF-8"?>
<Context sessionCookieDomain=".domain.com"/>

Open in new window

Note: if the "META-INF/context.xml" file already exists, just add the above attribute to the <Context> element that will already be there.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 39813660
You are trying to close this request by accepting your own comment. This is fine but the comment has no information about how your problem is solved, it was just a comment listing 2 things you had tried and why neither of those 2 things are acceptable. But now you say that it's solved.

Please leave a comment about exactly how your problem was solved and then you can accept that as the answer. Otherwise you should award points to any answers that have helped you.
0
 

Author Closing Comment

by:xiaoyunwu
ID: 39826061
this solves
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question