Pergunta

Meu redirecionamento não está funcionando, não vejo razão para que não esteja funcionando, alguém pode ver um motivo,

function createCookie() {
            $this->load->helper('url')
    // Function gets called when the user clicks yes on the firstTime menu.
    // The purpose of this function is to create a cookie for the user.
    // First we'll give them a unique ID
    // Set an expiration time
    $prefix = "bang";
    $unique = uniqid($prefix);
    $expireAt = time() + (60*60*24*30);
    // With the unique ID now available we can set our cookie doing the same function as before
    $_COOKIE[] = setcookie("bangUser", $unique, $expireAt, "/");
    // Now that the cookie is set we can do a 100% check, check that cookie is set and if it is redirect to
    // to the homepage
    if(isset($_COOKIE['bangUser'])) {

        // We need to save the cookie data to the database
        // First let's load the model for the cookies
        $this->load->model('cookieModel');
        if($this->cookieModel->saveCookieRecord($_COOKIE['bangUser'], $expireAt)) {
            redirect(base_url(), 'location');
        } else {
            die(var_dump($this->cookieModel->saveCookieRecord($_COOKIE['bangUser'], $expireAt)));
        }
    }
}

Se eu substituir o redirecionamento por dado (), no entanto, eu recebo o dado Messege.

Alguma ideia?

Foi útil?

Solução

Se você deseja ir 'para casa' para a base que você estabelece no seu arquivo de rota, basta colocar:

redirect('', 'location'); // Passing no URI parameters so it goes to base route

Se você quer ir a algum lugar com seu código, passe apenas os segmentos URI:

redirect('users/logout/', 'location');

GL, e deixe -me saber se isso não funcionar.

Outras dicas

Tente substituir base_url () por uri_string (). De Guia de usuario:

Você irá não Especifique o URL completo do site, mas simplesmente os segmentos URI para o controlador que você deseja direcionar.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top