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 6789239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:34:48+00:00 2026-05-26T17:34:48+00:00

I have some problems using Code Igniter and I feel there is something I

  • 0

I have some problems using Code Igniter and I feel there is something I don’t understand because I can’t get my redirects and my headers to work. Here is the situation :

When site is entered, the default “home” controller is called.

    public function initialize()
{
    printf("CONSTRUCTION OF HOME CONTROLLER - \n");
     //   print_r($_SESSION);
        //TODO : CONSIDER CREATING A LIBRARY TO AVOID WRITING THIS OFTEN. NOT

    // SESSION TROLLING DETECTION
        if( isset($_SESSION['banana']))
        {
            echo "SPLITTING THE TRUTH";
        }   

   // GETTING AS SERIOUS AS GREG     
        if( !isset($_SESSION['username']))
        {
            printf("USERNAME IS NOT SET. SETTING UP THE LOGIN PAGE. \n");
            redirect('home_invite');
        }
        else
        {
            $this->load->view('welcome_message');
        }
}

public function index()
{
    //INITIALIZING THE PATH USED FOR THIS NAVIGATION
    printf("TROLLING THE BEGINNING OF THIS CONTROLLER HOME - ");
     $this->initialize();
     printf("TROLLING THE END OF THIS CONTROLLER  HOME - ");
   //TODO : CONSIDER CREATING A LIBRARY TO AVOID WRITING THIS OFTEN
}

Index calls initialize who verify if the user has already a session variable with username in it. If that’s the case, we would proceed to check his level of privileges, etc, and load corresponding view. Thats not the problem.

If the session is not started, I want to load the “login” view, called here “home_invite”. And I want to redirect him to that page. But if I use this code, the page will show a 404 error.

If I use $this->load->view('home_invite'), it works, but I don’t understand and I feel it isn’t what I want it to do.

Why is redirect not working in this context?

  • 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-26T17:34:49+00:00Added an answer on May 26, 2026 at 5:34 pm

    Using the redirect() method redirects to a URL. You therefore need to pass it a full URL (as it uses the header() function which according to the RFC for HTTP1.1 requires a full URL.

    This means that you can use

    redirect(site_url('home_invite'));
    

    Which will redirect your user to http://www.yoursite.com/home_invite

    This means that you must have a controller called home_invite available as you can’t load a view from the URL. Equally you could create a method in your existing controller and use the routes.php file to masquerade /your_controller/home_invite as /home_invite

    The site_url() function is also part of the URL helper you’ve already included to use redirect().

    If you don’t want to use site_url(), you could just as well hard code the URL in like

    redirect('http://www.yoursite.com/home_invite');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problems using will_paginate and named routes. Here is some code (my
i have some problems in my code... I am using html and jquery.. i
I have some problems sending mails through SMTP using Spring's MailSender interface and the
I am using the new ASP control Chart, but I have some problems with
We have some performance problems with one of our applications. I thought about using
I have some problems using two dimensional array. static const int PATTERNS[20][4]; static void
I'm having some problems using / understanding is_dir. (Yes, I have read the PHP
We have some really old code that calls WebServices using behaviours (webservice.htc), and we
been recoding my site using code igniter. I am having some quirks with my
I'm using Rational Application Developer to create some web services. The problem I have

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.