Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!