Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 35
Registered: ‎12-20-2012
My Device: Limited Edition Z10
My Carrier: Telekom Slovenije
Accepted Solution

Set-Cookie header in QML

Hi,

I don't find solution for getting and setting xmlhttprequest "Set-Cookie" header. I need to send request first time to get this cookie and then send back request with the same "Set-Cookie" header and authentication data for user.

I prefer to do this in QML and javascript, without C++.

 

This is my code

 

function getCookie() {
var url = "some url";
var jsClient = new XMLHttpRequest();
jsClient.open("GET", url, true);
jsClient.withCredentials = true;
jsClient.setRequestHeader("Accept", "application/json");
jsClient.setRequestHeader("Accept", "text/html;charset=ISO-8859-1");
jsClient.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
jsClient.setRequestHeader("Access-Control-Allow-Credentials", "true");
jsClient.send();
jsClient.onreadystatechange = function() {
if (jsClient.readyState === 4) {
if (jsClient.status === 200) {
console.log("Cookie: "+jsClient.getResponseHeader("Set-Cookie"));
console.log("All headers: "+jsClient.getAllResponseHeaders());
//Set-Cookie is always null ? 
var setCookie=jsClient.getResponseHeader("Set-Cookie");
nextCall(setCookie);
} 
}
};
}
 

 

______________________________________________________________
Check my Apps http://appworld.blackberry.com/webstore/vendor/29747/?lang=en
Highlighted
Developer
Posts: 35
Registered: ‎12-20-2012
My Device: Limited Edition Z10
My Carrier: Telekom Slovenije

Re: Set-Cookie header in QML

I found a link which is solution to this answer. Smiley Sad

 

Get/Set cookies from qml

______________________________________________________________
Check my Apps http://appworld.blackberry.com/webstore/vendor/29747/?lang=en