• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

Attach Custom Cookie to AJAX Request

Question

Brian Miller    1,630

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");
	}
});

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.