Cookies for AJAX Requests -- How do they work?
I have an application that I am attempting to develop for Titanium Desktop to run on Mac and PC. While the main "guts" of the application are currently stored locally (so under the app:// system), the application makes heavy use of AJAX API calls to an external site.
The problem is that the Titanium application doesn't seem to be storing and sending back the cookies that the AJAX API is attempting to set. The API uses PHP sessions, so in theory I really only need to get one cookie set (the session ID), and then the rest can really just be handled server-side.
What's the solution here? In Adobe AIR this "just works" the way that one would expect (the same way a browser would handle it, basically). If I can just overcome this one obstacle I think I should be able to really get rolling on this project, but for now I'm about read to pull my hair out.
2 Answers
-
Accepted Answer
Titanium for Desktop is dead I think. Because they don't seem to reply to desktop based questions. Also, there are no updates to desktop. I was a convert from AIR to Ti but now back to AIR.
I also faced the same problem but then ultimately I had to use database file.
-
I realize this post is old but for those still encountering this issue, have you tried specifying
withCredentials = 'true'
?According to Apple's Documentation, you must specify
withCredentials = 'true'
or cookies will not be sent and received.Example
var req = new XMLHttpRequest(); req.open('GET', 'http://www.apple.com'); req.withCredentials = 'true'; req.onreadystatechange = function() { if (req.readyState==4 && req.status==200) { Titanium.API.info(req.responseText); } } response = req.send();