• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can not declare session check in contractor in ci4

#1
I was trying to protect full controller class from non authorize user so I use

PHP Code:
if(! session()->has('isLogged'))
{
return 
redirect()-route('loginPage');


Buh will not work untill I put that same code in each method before it effect.

Any way to make it for the whole controller?
Reply

#2
Sounds like you're looking for a before filter - https://codeigniter4.github.io/userguide...lters.html
Reply

#3
(03-31-2020, 04:25 AM)maxxd Wrote: Sounds like you're looking for a before filter - https://codeigniter4.github.io/userguide...lters.html


That save my day. A big Thank you.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.