Session variable lost after setting it in ajax call
I'd assume those are 2 different sessions; use session_id()in both contexts to confirm.

To make sure you're using the same session, just implement your AJAX path inside Drupal, with hook_menu()