使用CodeIgniter进行用户验证

编程入门 行业动态 更新时间:2024-10-16 16:21:48
本文介绍了使用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',并且有一些结果可能有助于: codeigniter/ wiki /

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

更多推荐

使用CodeIgniter进行用户验证

本文发布于:2023-10-31 13:28:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546221.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   CodeIgniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!