I'm having difficulty retrieving a $ _SESSION using native php session with ajax in codeigniter, since when I try to check the data it reports undefined. follow the code, already thanks to all.
controller login
if($user->cod_user == 1)
{
$_SESSION['admin'] = $user->name;
echo "<script>location.href='admin';</script>";
}
else if($user->cod_user == 2)
{
$_SESSION['admin'] = $user->name;
echo "<script>location.href='vendedor';</script>";
}
In the view you receive (admin or seller) it arrives as undefined
I'm suspecting how I'm doing redirect with javascript, because in this msm controller I can view the normal session.
ajax request
$(function(){
$('#gestao').slideDown('slow');
// efetua login no sistema
$('#bt_login').click(function(){
$.post('<?php echo site_url()?>/Login', $('#form_login').serialize())
.done(function(data){
$('#msg_erro').html(data);
});
});
});