0

リダイレクトが機能していません。機能していない理由はわかりませんが、誰かが理由を見ることができますか?

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

リダイレクトを die() に置き換えると、ダイメッセージが表示されます。

何か案は?

4

2 に答える 2

4

ルートファイルで確立したベースに「ホーム」に移動したい場合は、次のように入力します。

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

コードを実際にどこかに行きたい場合は、URIセグメントのみを渡します。

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

GL、それがうまくいかない場合は私に知らせてください。

于 2010-02-15T16:19:28.543 に答える
2

base_url() を uri_string() に置き換えてみてください。ユーザーガイドから:

完全なサイト URL を指定するのではなく、送信先のコントローラーへの URI セグメントを指定するだけです。

于 2010-02-15T13:07:53.940 に答える