I’m creating a widget (with PHP and jQuery) to be included in a hosting webpage,
and actually I’m kind of stuck because of these two isseus i’m describing below:
-
In my widget there are commands that are supposed to perform AJAX calls to php script to
retrieve data, but I always got access-Control-Allow-Origin errors, initially I thought I solved this issue placing this line in php:
header(“Access-Control-Allow-Origin: *”);
But it is working until now only on firefox, Chrome still refuse to give me the php output -
Always talking about the AJAX calls : the user performs choices lauching these calls, I’d like to track user choices. I thought to use sessions with PHP. The problem here is that any call seems to have a different session_id… any idea?
Thanks in advance
Explanations for your issue #2: PHP sessions work with cookies and GET parameters. PHP generates sessions ID and puts it to either cookie or GET string. Then, when request comes back, it reads the cookie (GET param) and knows which sessions to pick up. In your case you get cookies from the original page (not your domain) and thus no session id (that belongs to your server) is in and your server has nothing to do except generate the new one.
As an option you may consider embedding your widget with
iframeand it will solve all your issues including same origin and session handling.