Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4001294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:53:13+00:00 2026-05-20T07:53:13+00:00

I have a CI app that has a auth controller and switchuser function. Basically

  • 0

I have a CI app that has a auth controller and switchuser function. Basically all it does it take an ID from the URI, get some user data from the ID, assign some session data then load a view.

function switch_user(){
    if(!$this->auth_lib->is_admin()){
       $this->session->set_flashdata('status', 'You need to be an administrator to access this page.');
       redirect('auth/login');
    }

    if($id = $this->uri->segment(3)):
            $this->load->model('auth_model', 'auth');
            $username = $this->auth->get_username($id)->account_name;
            $this->session->set_userdata(array('at_id' => $id, 'username' => $username));
            $this->session->set_flashdata('status','User switched.');
    endif;
    $this->load->model('clients_model', 'clients');
    $data['users'] = $this->clients->get_at_clients();
    $this->load->view('auth/switch', $data);
}

I’m getting the following error:

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cp\application\controllers\auth.php:130)

Line 130 is $username = $this->auth->get_username($id)->account_name;

Here is the model function:

function get_username($at_id){
     $portal = $this->load->database('warehouse', TRUE);
     $portal->select('account_name');
     $portal->where('account_id', $at_id);
     $portal->from('wh_account');

     $query = $portal->get()->result();

     return $query[0];
}

I don’t understand what’s happening. When I run the code locally I don’t get the error. But when I run it remotely i.e over the internet I get that headers error.

Can anyone help identify the problem?

Thanks,

Billy

UPDATE

I had actually put a var_dump around the $username = $this->auth->get_username($id)->account_name;
line which was causing the error. I don’t know know why though 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:53:13+00:00Added an answer on May 20, 2026 at 7:53 am

    I would check that you have no closing PHP tag in any of your models, controllers or libraries – this will often cause this type of error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small app that has a Render thread. All this thread does
I have a rails app that has picked up a bit of traction, but
I have an existing app that has many, many models. I'd like to log
This is an interesting conundrum. We have a WPF app that has a Vista-like
I have a standalone Java app that has some licensing code that I want
I seem to have an app on my Dev server that has lots of
I have a Cocoa app I'm writing that has an ImageView with a TextView
I have a Windows Forms app, that has a single ElementHost containing a WPF
I have been working on an iPhone app that has a feature of uploading
I have an app that has settings the user can pick before running the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.