I initially asked for the login interface. After the login was successful, I asked for the data interface and returned not logged in.
so I separate the login API from the data interface and put it in a separate html file, and then test and find that the, session id is consistent if the request is successful.
then the data interface in the project can also request successfully, but once the login period expires, the data interface in the project returns not logged in again.
as long as I refresh the separate html (including login interface and data interface), the data interface in the project can be requested successfully
background is java
I have looked up a lot of information on the Internet, which is basically different from my situation. After
, I also tried to delay the data interface with setTimeout because of asynchronism, but it was not successful.
$.ajax({
url:"http://server/admin/login",
type:"post",
data:{username:"xxx",pw:"xxx"},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success:function(res){
console.log(res)
//
}
})
setTimeout(function(){
$.ajax({
url:"http://server/admin/getData",
type:"post",
data:{id:"10031",coin:"$",amunt:"1000"},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success:function(res){
console.log(res)
//
//sessionidsessionid
}
})
},2000)
I don"t know why the request can be successful after taking out the login interface and the data interface separately, but the unlogged, session id change is returned in the project?