• 0

Attach Custom Cookie to AJAX Request


Question

I was wondering if it's possible to send up additional headers is in custom cookies to an AJAX request, as composed through jQuery? Below is what I am proposing.  You notice that I am attempting to set the cookie called "TestCookie1" one and "TestCookie2". Both methods seem to fail.  Any advice would be much appreciated.

 

$.ajax({
	cache:		false,
	xhrFields:	{withCredentials:true},
	type:		"POST",
	headers:	{"Cookie":"TestCookie1=AAA"},
	cookie:		"TestCookie2=AAA",
	url:		"/somepage.php",
	data:		JSON.stringify({"foo":"bar"}),
	dataType:	"json",
	contentType:	"application/json",
	success: function($Response){
		alert("Success");
	},
	error: function($Response){
		alert("Error");
	}
});

 

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.