douzhantanju1849
2012-01-29 02:02
浏览 37
已采纳

如何使用CodeIgniter管理会话和用户?

I'm in the middle of moving my site into the CodeIgniter framework. I've never used a MVC framework before so this is a big step.

In my old site, each page would have include("session_handler.php"); at the top of each page. This script would check session variables, authenticate sessions and store stuff in the database.

Is there a way I can have this script automatically include in every page? Can I specify it in the config? Does CI maybe have an internal way of dealing with sessions that is superior to my method?

图片转代码服务由CSDN问答提供 功能建议

我正在将我的网站迁移到CodeIgniter框架中。 我之前从未使用过MVC框架,所以这是一个很大的进步。

在我的旧网站中,每个页面都有 include(“session_handler.php”); 在每个页面的顶部。 这个脚本会检查会话变量,验证会话并在数据库中存储东西。

有没有办法让这个脚本自动包含在每个页面中? 我可以在配置中指定它吗? CI可能有一种内部方式来处理优于我的方法的会话吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyin0628 2012-01-29 02:08
    已采纳

    Code Igniter has a Session class you can use.

    It also has an autoload functionality.

    Those two things should cover your requirements I think...

    If you need additional validation to the session, you can either extend the core session class (which may be asking too much if you're only starting on the framework) or you can create your own library and auto-load it right after the session one to run some additional code..

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题