Hello everyone,
can someone tell me, how I can send Cookies to a Server with XHR?
I read this site
http://wiki.forum.nokia.com/index.ph...s_and_with_XHR,
but I don't really understand how I can use it.
Hope someone can help me.
thanx
florianhaar
Hello everyone,
can someone tell me, how I can send Cookies to a Server with XHR?
I read this site
http://wiki.forum.nokia.com/index.ph...s_and_with_XHR,
but I don't really understand how I can use it.
Hope someone can help me.
thanx
florianhaar
Hi florianhaar,
I've not tested cookies within WRT widgets yet, anyway from this Wiki article it seems that widgets automatically manage cookies when loading HTTP resources via XMLHttpRequest, so you have not to do anything else to manage them.
Have you already tried to use them in your widget? Are you experiencing any specific issues?
Pit
Hi jappit,
I tested document.cookie. But know I need to send this cookie to the server with xmlhttprequest. But I don't know how I can do it.
Hope you or someone can help me.
thanx
florianhaar
The Wiki article says that you cannot access Cookies via JavaScript in WRT widgets. Anyway, your server should (theoretically) be able to read them without any JavaScript code: have you checked this on the server side?
Pit
ok, but how does the server know that i have a cookie or not.
It does not get in my mind.
sorry
Cookie management is inbuilt in browsers, and cookies' information is transferred to the remote server (in the subsequent HTTP requests) without the need to manually send it via JavaScript. So, WRT widgets should work the very same way (I say 'should' as I've not tested this by myself).
You can find a lot of introductions and info about cookies on the net, as this:
http://en.wikipedia.org/wiki/HTTP_cookie
Pit
thank you again jappit i would look and test.
florianhaar
Hello again,
I found that i must use this:
var client = new XMLHttpRequest();
client.open("POST", url, false);
client.setRequestHeader("Cookie"," test=tests");
client.onreadystatechange = function() {
if(client.readyState == 4 && client.status == 200){
alert(client.getAllResponseHeaders());
document.getElementById('test').innerHTML = client.responseText;
}
}
to set a cookie, but that doesn't work.
So what is wrong, or does the WRT not work with cookies allright?
Can someone help?
thanx
florianhaar
Hi florianhaar,
I've just done a quick test, and I wasn't unable to get cookies working in a WRT widget.
I've set up two pages:
1) http://www.jappit.com/m/wrt/cookies/cookie_set.php - sends the cookie to th client
2) http://www.jappit.com/m/wrt/cookies/cookie_get.php - read back and displays the cookie from the client
Calling 1) and 2) from the browser, the cookie is correctly set and read back. Anyway, in the WRT widget (on real device) it doesn't seem to work (the test widget is available here: http://www.jappit.com/m/wrt/cookies/CookieTest.wgz)
Will let you know if I find any working solutions,
Pit
Thank you very much.
It helps. Now I know that the WRT can't send cookies. That is bad, but I don't can do anything. So now I need another way to send my informations.
Thanx
florianhaar