I can not recover the $ _SESSION with ajax and codeigniter

0

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);


            });

        });
    });
    
asked by anonymous 10.03.2017 / 03:41

0 answers