I followed the wikihow tutorial for building a secure session management system : http://www.wikihow.com/Create-a-Secure-Session-Managment-System-in-PHP-and-MySQL
and it
When you make the first AJAX call, the server starts a session and sends the session ID back to the browser in a cookie. In order for the second AJAX call to be in the same session, it has to send that cookie back to the server.
But you're not waiting for the response to the first call before you send the second call. So the cookie hasn't been received, and it can't be sent with the second call. Anything that depends on the result of an AJAX call has to be done in its callback function. So you should do:
$.get('ajax1.php', function() {
$.get('ajax2.php');
});