Hello, I'm using inheritors that are my controllers:
-baseAdminController
& lt ;? Php if (! Defined ('BASEPATH')) Exit ('no direct script entry is allowed'); Class _BaseAdminController Expands CI_Controller {Public Function __construct () {Origin: __ Construction (); $ This- & gt; Load-> Library ('session'); $ Function named $ = this- & gt; Router- & gt; Fetch_method (); If ($ function called $ = 'log in view' & $ function! = 'Dolugin') {$ this-> Check session (); }} Public Function Check Session () (if ($ this-> Session-> User Data ('Login') == Incorrect) {$ this-> Load-> View ('Admin / Login view ');}} and my derived admin controller:
if (! Define' BASEPATH ') exit (' no direct Script entry is not allowed '); Class AdminController _BaseAdminController {View Public Function Index () ($ )-> {$ this-> Load-> View (' Admin / Indexview ');}} h I am tring to login, CodeIgniter shows me both admin / loginview and admin / indexView because I am checking session status in the creation of my derivative controller.
< Div class = "post-text" itemprop = "text">
How do I prevent other views to load?
To answer your question, The check session could have the following functions:
public function check value () (If ($ this- & gt; Session-> Userdata ('loggedIn') == false) {echo $ this-> Load-> View ('admin / loginView', array (), true); Go out; }} Explanation: If you tell the third argument the truth, then it will return the contents of that file. For more information, read.
No comments:
Post a Comment