ajax 设置jsessionid,jquery - Tomcat - AJAX calls using correct JSESSIONID - Stack Overflow

I login into a tomcat instance at mywebsite1.web.com where I get a JSESSIONID. As part of browsing activity I go to a different tomcat instance at mywebsite2.web.com - where I get a different JSESSIONID.

As part of an activity, I need to make an AJAX POST call to mywebsite1.web.com/user_activity. What I understand is that the JSESSIONID for mywebsite1.web.com will not be passed unless I pass withCredentials to true. In other words, if I do the following from mywebsite2.web.com/a_random_browser_page:

$.ajaxSetup({

url: "mywebsite1.web.com/user_activity",

global: false,

type: "POST",

xhrFields: {

withCredentials: true

}

});

$.ajax({ data: '' });

Would I be sending the correct JSESSIONID (originally issued by 'mywebsite1.web.com' at the beginning) ? Do I need to set any additional headers at mywebsite1.web.com to get this working?

** Note **

I am setting the following headers on my response

("Access-Control-Allow-Origin", "https://mywebsite2.web.com");

("Access-Control-Allow-Credentials", "true");

("Access-Control-Allow-Methods", "GET,PUT,POST,OPTIONS");

("Access-Control-Allow-Headers", "Content-Type,Accept,X-Requested-With,Session")

I tried to hit the URL with my browser and it works successfully and shows the headers correctly on the dev console inspector. So I am not sure what's wrong here.

Thanks,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值