使用CodeIgniter进行用户验证 [英] User authentication with CodeIgniter

查看:112
本文介绍了使用CodeIgniter进行用户验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP编写一个Web应用程序。我想为此使用MVC模式,并决定使用 CodeIgniter 。我的应用程序将有一些页面需要身份验证,一些页面不会。我想设计一个非常通用的方式,所以应该没有代码重复。可以任何一个指向一些好的设计/类结构为此?

I am writing a web application using PHP. I want to use the MVC pattern for this, and decided to go with CodeIgniter. My application will have some pages which will require authentication, and some pages won't. I want to design this in a very generic way, so that there should be no code duplication. Can any one point to some good "design/class structure" for this?

推荐答案

写一个自定义库,你的代码igniter应用程序在每个页面视图。它应该具有以下功能:

Write a custom library that you can autoload in your code igniter app on every page view. It should have functions that:


  • 验证用户ie。检查用户是否登录。

  • 登录ie。

然后在您的控制器类中,您可以在构造函数中调用身份验证函数,然后根据结果继续正常,或将它们重定向到具有访问被拒绝消息的登录屏幕。

Then in your controller classes you can do a call to the authentication function in the constructor then depending on the outcome continue as normal or redirect them to a login screen with an access denied message.

执行搜索代码igniter wiki for'authentication',并且有一些结果可能有助于: http://codeigniter.com/ wiki /

Do a search on the code igniter wiki for 'authentication' and there are a number of results that may help: http://codeigniter.com/wiki/

这篇关于使用CodeIgniter进行用户验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆