Avatar of Amzngmoe
Amzngmoe
 asked on

HELP!!! PLEASE!!! Ajax calls create new session when I don't want it to.

Good afternoon all,

I have been stuck on a problem for a long time and I am hoping that somebody here has a solution for me.  I am building a web application using java with jquery and ajax.  Due to security reasons, things beyond my control, access to my application has to be forwarded from appache via https to a secure port on tomcat.  My problem is that each time an ajax call is made it is creating new sessions instead of finding the one that was created during the login.  During the execution of an application there could be as many as 20 sessions created.  How do I fix this problem?  Is there a way to force ajax to stop creating new sessions?  I am desperate.
JavaApache Web ServerJSP

Avatar of undefined
Last Comment
Amzngmoe

8/22/2022 - Mon
CEHJ

mrcoffee365

Ajax requests to the server should not be making new tomcat sessions.  There are some circumstances where new sessions are created when requests are made.  If you don't return the cookie (which ajax should do by default -- but are these different domains?) -- then each connection will make a new session.  If you have to log in every time, then each login will make a new session.  There are some flags to give tomcat which can prevent some of this, but you need to be careful.  

So perhaps there is something wrong with how your Ajax requests are being made.  If you can give more description of the problem, we're more likely to be able to help.
dpearson

It sounds to me like the apache server may not be forwarding the cookies in the request to Tomcat - so Tomcat sees each request as new and creates a new session.

I'd suggest investigating the headers that are received by apache and comparing them to the headers being received by Tomcat on the request.  If the cookies are indeed being dropped then you would need to fix this in the way Apache is forwarding the requests.

Doug
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Valeri

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Amzngmoe

ASKER
Yes it is a cross domain request.  I will try all of your suggestion.  Thank you so much.
Amzngmoe

ASKER
This solved my problem and I am eternally grateful for the help.  Thank you so much.