Frage

Meine Umleitung funktioniert nicht, sehe ich keinen Grund, warum es nicht funktioniert thouhg ist, kann jeder sehen, ein Grund,

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)));
        }
    }
}

Wenn ich die Umleitung mit sterben replace () aber ich den Chip messege bekommen.

Irgendwelche Ideen?

War es hilfreich?

Lösung

Wenn Sie gehen wollen, sind ‚zu Hause‘ an die Basis in Ihrer Routendatei aufzubauen nur gesagt:

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

Wenn Sie wirklich wollen, gehen irgendwo mit Ihrem Code nur die URI-Segmente übergeben:

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

GL, und lassen Sie mich wissen, wenn das nicht funktioniert.

Andere Tipps

Versuchen Sie ersetzen base_url () mit uri_string (). Aus der Benutzerhandbuch :

  

Sie wird nicht geben Sie die vollständige Site-URL, sondern einfach die URI-Segmente an den Controller mögen Sie richten.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top