模仿 CodeIgniter 中退出的使用的类似方法
我是 CodeIgniter 的新手。以前,我开发了一个登录脚本,通过使用类似于以下内容的行,可以使登录页面看起来与用户正在查看的页面相同:
include('loginpage.php');
exit;
但是使用 CodeIgniter 时,以下结果不会显示任何内容,因为输出的功能类尚未完全执行:
$this->load->view('loginpage');
exit;
所以我的问题是:是否有任何替代方法来模仿我以前的方法的功能?最终,我更喜欢这种方法,因为对于用户来说,他们似乎位于他们请求的页面上,只有他们需要先登录才能看到它(如果他们还没有登录)。
I'm new to CodeIgniter. Previously I had developed a login script that would make it so that the login page appeared to be the same page the user was viewing by having lines similar to the following:
include('loginpage.php');
exit;
But with CodeIgniter the following results in nothing being displayed because the functionality of the output class hasn't been fully executed:
$this->load->view('loginpage');
exit;
So my question is: Are there any alternative means to mimic the functionality from my previous method? Ultimately I prefer this approach because it appears to the use that they are on the page they requested only they need to log in first to see it if they haven't already.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
Try:
在 codeigniter 中执行此操作的一种方法是在控制器类中,首先检查登录。这可以在构造函数中完成:
该函数将在任何其他控制器操作之前执行。如果您在整个应用程序中全局需要此功能,并且您有多个控制器,请使任何控制器从特定于您的应用程序的基本控制器扩展。请参阅 http://codeigniter.com/user_guide/general 中的替换核心类 /core_classes.html 。
One way to do that in codeigniter is that inside your controller class, you check the login first. That can be done in the constructor:
That function will get executed before any other controller action. If you need this globally within your whole application and you have got multiple controllers, make any of your controllers extend from a base controller that is specific for your application. See Replacing Core Classes in http://codeigniter.com/user_guide/general/core_classes.html .