开发者

What's the best practice with Codeigniter routes and sessions?

开发者 https://www.devze.com 2023-02-10 01:08 出处:网络
When using CI routes, I have the default route which points somewhere, but I want it to point to another place if the user is logged in.

When using CI routes, I have the default route which points somewhere, but I want it to point to another place if the user is logged in.

Whats the best way of doing this?

开发者_如何学Go

Edit

I don't think I wrote this question as clearly as I should have. What I mean is that if the user is not logged in and they go to www.domain.com/ they go to the home page. If they are logged in and they go to the same URL they see a different page, but the same URL in the address bar


Basically as Malachi said, one way to do this is:

class MY_Controller extends Controller {

    function __construct()
    {
        if($this->auth_library->is_logged_in()) 
        { 
            redirect('my_logged_in_page');
        }
        // else...redirect to login?
    }

}

 // call it...   
class some_controller extends MY_Controller {
    // etc
}
0

精彩评论

暂无评论...
验证码 换一张
取 消