Solved

change domain of JSESSIONID cookie in Apache

Posted on 2013-12-18
8
1,712 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
  • 3
  • 2
  • 2
8 Comments
 
LVL 82

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 82

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 35

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 35

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now