Get session cookie ID from AJAX response

Hi,

I am getting the following response from my AJAX GET. I need to grab the enteliWebID from the set-cookie header response, anyone got a way to do this:

HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: application/xml; charset=utf-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/8.5
Set-Cookie: user=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/enteliweb
Set-Cookie: pw=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/enteliweb
Set-Cookie: enteliWebID=3h8b057krl8d2guu264qq67qm3; path=/enteliweb; HttpOnly
Date: Mon, 21 Sep 2015 18:29:16 GMT
Content-Length: 171

Open in new window

LVL 1
wint100Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You can try something like this
<script>
var headerStr = 'HTTP/1.1 200 OK \
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 \
Pragma: no-cache \
Content-Type: application/xml; charset=utf-8 \
Expires: Thu, 19 Nov 1981 08:52:00 GMT \
Server: Microsoft-IIS/8.5 \
Set-Cookie: user=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/enteliweb \
Set-Cookie: pw=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/enteliweb \
Set-Cookie: enteliWebID=3h8b057krl8d2guu264qq67qm3; path=/enteliweb; HttpOnly \
Date: Mon, 21 Sep 2015 18:29:16 GMT \
Content-Length: 171';

var result = headerStr.match(/Set\-Cookie: enteliWebID=(.*?);/);

// RESULT IS IN INDEX 1 OF RETURNED MATCH

alert(result[1]);
</script>

Open in new window

0
wint100Author Commented:
Thanks. That text was from fiddler so not sure how I'd get that from the AJAX response in JS.
0
Julian HansenCommented:
Just had a look at your header again
Set-Cookie: enteliWebID=3h8b057krl8d2guu264qq67qm3; path=/enteliweb; HttpOnly \

HttpOnly means this cookie is only accessible from the Server.

You will need to get that value some other way.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.