Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

change domain of JSESSIONID cookie in Apache

Posted on 2013-12-18
8
Medium Priority
?
2,290 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 84

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 84

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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

598 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