Thursday, 8 August 2013

retrieving session via cross domain ajax

retrieving session via cross domain ajax

Background:
I'm developing a website tracker using javascript. Here's how it works:
1) A user visits any domain the tracker script is on "anydomain.com". The
script makes a successful ajax call in the background to my master domain
"masterdomain.com".
2) When "masterdomain.com" receives a request, the following PSEUDO code
is run. It works by checking for an existing session and if one doesnt
exist it creates a new one.
The first call appears to be fine because I am able to receive a session
ID in a response. However, each successive call to "masterdomain.com"
creates a new session. AKA the server doesn't find the "should be"
existing session.
Sample PSEUDO Code:
if(session exists)
{
// update timestamp for session
}
else
{
// set a new session for visitor
}
// load template
api(array("accepted"=>session_id),callback);
Some Quick Facts:
1) This does not appear to be a same origin issue (as I am able to
communicate with the server fine).
2) I have tried this with cookies/sessions both appear to not be working.
3) I am using codeigniter (sessions are set not to expire on page close).
I have also tried using/not using database sessions).
This problem can also be solved if there is another way to uniquely
identify a user each time a page loads on a server (not using IP).
Any help would be greatly appreciated as I'm about ready to tear the rest
of my hair out of my head!!!! :(

No comments:

Post a Comment