Reputation: 15429
Related to How can I replicate this cookie functionality on my Web Client?
I discovered in a previous question that I need to set a cookie in my request header.
I call a login method on a 3rd party web service, this returns a cookie that I need to use on subsequent requests to that server. I had assumed that the browser keeps this cookie and attaches it to the appropriate request, however, this does not seem to be the case (I can see it isn't in firebug).
How can I set the cookie on my request header?
My call is as follows:
var call = serviceUriString + '?' + strRequest;
$.post(call, function(d) {}, 'text').success(function(d) { ..//do something
I think I may have to use jQuery.ajax( url [, settings] ) beforesend, but I can't find any good examples of how to set the cookie, or indeed how to get it out / persist it from the response from the previous login request (so that I can then attach it).
As @edr points out, I am doing this client side. So my website calls a web service in client side code.
Upvotes: 2
Views: 4944
Reputation: 15429
I'm not sure if there is an answer to this, however I can add ;jsessionid=[value_here]?
to my url and that works.
For example:
var call = serviceUriString + ';jsessionid=' + [value_here] + '?' + strRequest;
$.post(call, function(d) {}, 'text').success(function(d) { ..//do something
similar answer is here: https://stackoverflow.com/a/10353875
Upvotes: 1
Reputation: 13256
Just speculating here:
Since cookies go along for the ride when doing ajax calls I suspect that the cookie created is for the 3rd party domain so it stand to reason that you will not find it in the cookies for your domain.
Try adding the cookie in client code before doing the post. This SO question may help:
How do I set/unset cookie with jQuery?
Upvotes: 0