0
I’m having trouble recovering a $_SESSION using php native Session with ajax in codeigniter, because when I try to verify the data informUndefined. follows the code, since 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) arrives as Undefined
I suspect the way I’m doing the redirect with javascript, because in this msm controller I can visualize the normal.
ajax requisition
$(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);
});
});
});
If the data is coming you have no reason why not store, check if the session has been flattened and debug the user object with var_dump()
– Felipe Duarte
this part of the object this tranquil Elipe because I’ve debugged returning in ajax. this part q ta sinister na hr q i do the redirect with javascript but it’s not coming in view :/
– Flavio Domingos
and in the __Construct controller I’ve already put $this->load->library('Session');
– Flavio Domingos
weird, make sure you also posted in admin/seller views
– Felipe Duarte