Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

329
Vistas
Deactivated user redirect to login from ajax request

Can anyone tell me the best practice to check if the user is activated and logged-in? And how can I handle it from ajax request?

If a user is deactivated, redirect to the login page via ajax request on a controller.

I'm making a helper function and calling it in the constructor.

But it not redirecting to the login if the user is deactivated and return "Status Code: 303 See Other"

In controller:

function __construct()
{
    parent::__construct();
    $this->load->helper('auth_helper');
    if (!auth())
    {
        redirect('login/login_panel');
    }
}

Helper function:

function auth()
{

    $CI =& get_instance();

    $user = true;
    if ($CI->session->userdata('user_id')) {
        $CI->load->model('users_model');
        $active = $CI->users_model->getActive($CI->session->userdata('user_id'));
        if ($active->active == '0' || $active->active == null) {
            $user = false;
        }
    } else {
        $user = false;
    }

    return $user;
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

try this

function __construct()
{
    parent::__construct();
    $this->load->helper('auth_helper');
    if (!auth())
    {
        header('Location: login/login_panel');
        exit();
    }
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda