User authentication with CodeIgniter

前端 未结 7 973
名媛妹妹
名媛妹妹 2021-02-05 19:22

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 auth

相关标签:
7条回答
  • 2021-02-05 20:18

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

    • Authenticate the user ie. check if a user is logged in or not
    • Log you in ie. set a session variable or something
    • Log you out

    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.

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

    0 讨论(0)
提交回复
热议问题