authentication |
(04-16-2020, 11:01 AM)oh so does that mean its ok to verify the session in every controller that I require to protect from unauthorized user Wrote: like so: It can be. I usually make a function that checks if the user is logged in, in the BaseController. Something like this: PHP Code: class BaseController extends Controller This way you can call this function from any controller, like admin, or users, or home or whatever - and you can set what you want be done from there - quick and easy. Maybe you want them kicked to login screen, or show them 404 if its a sensitive administrator only page. While a Login controller, PHS was talking about, handles the actual logging in part, (and maybe it can also have registration and user delete and other user related methods) THIS little function handles the actual CHECKING of being logged in. Now you can just write one line from any controller to perform a check. Like this: class Def_nivel extends BaseController { public function index() { $this->check_login(); echo view('common/header'); echo view('common/sidebar'); echo view('definicoes_view/nivel'); echo view('common/footer'); } } Much cleaner
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.
|
Messages In This Thread |
authentication - by joseCarlos - 04-16-2020, 04:04 AM
RE: authentication - by Leo - 04-16-2020, 06:00 AM
RE: authentication - by joseCarlos - 04-16-2020, 06:26 AM
RE: authentication - by PHS - 04-16-2020, 10:46 AM
RE: authentication - by joseCarlos - 04-16-2020, 11:01 AM
RE: authentication - by Leo - 04-16-2020, 01:37 PM
RE: authentication - by joseCarlos - 04-16-2020, 02:37 PM
|