Hello,
I have a problem in server side retrieving session with using ajax post request. Here is my sample code:
JavaScript:
$(function() {
$('.jid_hidden_data').submit(function() {
var serialized = $(this).serialize();
var sUrl = "http://localhost/stuff";
$.ajax({
url: sUrl,
type: "POST",
data: serialized,
success: function(data) {
alert(data);
}
})
return false;
});
});
CodeIngiter(PHP) side:
function stuff()
{
$post_stuff = $this->input->post('my_stuff'); // WORKS PERFECTLY
$user_id = $this->session->userdata('user_id'); // RETURNS NULL
}
Where commented returns NULL it should return users session data, because it really exists. What is the problem? Method post doesn't get cookies or what? Thanks for any help!
Update:
For clarification i have session set with $this->session->set_userdata($data). And I don't have a problem when posting it without js/ajax. I mean with plain form submit it works fine.