Empty sessions in Rails 3 when using jQuery AJAX requests

This problem has been addressed, but it took me a little while to find. What you need to do is explicitly tell jQuery to send the CSRF token along with every AJAX request:

1
2
3
4
$(document).ajaxSend(function(e, xhr, options) {
  var token = $("meta[name='csrf-token']").attr("content");
  xhr.setRequestHeader("X-CSRF-Token", token);
});

Just stick that somewhere in your layout head and your sessions should come back :)