I am puzzled by this ... I am setting up remote widgets, we will control both domains, so security is not a concern. I use jsonp to allow ajax requests for cross domains.
The visited site is domain1.com, which includes:
<script src="domain2.com/file.js"></script>
file.js uses jQuery to create ajax requests:
$.ajax({ url: 'http://domain2.com/getdata', dataType: 'jsonp', success: function(response) { div.html( response ); } });
It goes through several of these steps as a wizard, reloading the div with html from the remote server.
The problem I ran into is that with every ajax request I get a new php session id and my session data goes away. The PHP end of things is fine, if I run the same script from the same domain (still using jsonp), everything works fine. However, do this from a remote domain, and the session does not close. I have no idea why this is so, php end sets and requests a cookie from its own domain. I do not need to access the cookie from JS. A cookie is recorded and stored on the server. But each request, when I check the stored cookies in the browser, changed the session ID.
Any ideas?
source share