I need to set session in Jquery but when i try it does not work this is i am doing in jquery
var a = 22;
<?php $this->session->set_userdata('friend_id' ,a )?>
it gives me syntax error, anyone knows how to solve it.
in jquery you can do this:
$.ajax({
type: "POST",
url: 'test.php',
data: '{"var":"yourvar"}',
success: function (data) {
console.log("Success!!");
},
error: function (xhr, desc, err) {
console.log('error');
}
});
and after into your file test.php
<?php $this->session->set_userdata('friend_id' ,$_POST['var'] )?>
MANUAL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With