I know this has been asked many times and it was solved by others using withCrendentials and useDefaultXhrHeader. Somehow, I still don't see the cookie being passed and I've absolutely no idea why this is happening. May be I'm missing something?
Below is the code for log-in:
Code:
Ext.Ajax.request({
url: 'http://xxx.com/PostAuthentication',
method: 'post',
withCredentials: true,
useDefaultXhrHeader: false,
params: {
username: this.getUserName().getValue(),
password: this.getPassWord().getValue()
},
success: function(result, request) {
console.log(result);
},
failure: function(response) {
console.log(response);
},
});
The above code does a post and gets the cookie and session back. After getting the cookie, I make the next call below:
Code:
Ext.define('Auth.store.MyStore', {
extend: 'Ext.data.Store',
alias: 'widget.myStore',
requires: [
'Auth.model.MyModel',
],
config: {
model: 'Auth.model.MyModel',
autoLoad: false,
proxy: {
type: 'ajax',
method: 'GET',
withCredentials: true,
useDefaultXhrHeader: false,
url: 'http://xxx.com/GetMyValues',
reader: {
type: 'json',
rootProperty: 'abc.xyz'
}
},
listeners:
{
exception: function (proxy, response, operation) {
Ext.Msg.alert('', 'Unable to load!', Ext.emptyFn);
}
}
}
});
The above request doesn't send the cookies. I've looked around a lot and it may be a case of same-origin policy. I'm calling these files from my localhost which is not the domain http://xxx.com/. Is this one of the reason its not making those calls?
If its because of the same-origin policy, what will be the origin (request-headers) from ipad or iphone? I'm sure someone must have tackled this situation before.
Please let me know if you need more info. Thanks in advance!