我的重定向不工作,我不明白为什么它不工作thouhg,任何人都可以明白了一个道理,

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

如果我替换模具(重定向)但是我得到的模messege。

任何想法?

有帮助吗?

解决方案

如果你想要去“家”给你在你的路由文件建立基地只是把:

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

如果要真正地与你的代码的地方去只有通过URI段:

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

GL,让我知道这是行不通的。

其他提示

尝试用uri_string替换BASE_URL()()。从用户指南

  

您的不可以指定完整的网站网址,而只需将URI段的控制器,你想直接到。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top