return error from form - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: return error from form (/showthread.php?tid=77131) |
return error from form - 68thorby68 - 07-23-2020 Hi, I'm trying to use Language files in CI4 for (amongst other things) customs errors. However, I'm not sure how to construct a response to a form submission with a customer error? PHP Code: if(empty($a) && !empty($b)) { I'm sure there is a simple process to achieve this? Any assistance is appreciated RE: return error from form - InsiteFX - 07-23-2020 Download and look at the Myth/Auth AurhController and views and they will show you how it is done. Myth:Auth RE: return error from form - 68thorby68 - 07-23-2020 Wow, very cool. Thank you. Also looks like I need to use myth:Auth instead of trying to reinvent the wheel. Many thanks. RE: return error from form - InsiteFX - 07-23-2020 Your very welcome. A lot of us on here are using it, I use it with Boilerplate which is AdminLTE 3 backend Dashboard. and I' am adding my Blog into it now. RE: return error from form - 68thorby68 - 07-23-2020 (07-23-2020, 08:45 AM)InsiteFX Wrote: Your very welcome. Yes I'm getting on with it very well. Just one question though? When I login the user I set additional session data (AuthController::attemptLogin), this works very well. However, if session expires and user is still logged in ($this->auth->check()) I need to add the additional session data again. PHP Code: public function login() So I tried to configure a filter to check the session data exists and if not, redirect to login. But I get caught in an infinite loop. Filter PHP Code: public function before(RequestInterface $request) { I'm not sure why because if I type http://mysite/login direct into browser, all is OK Any ideas? RE: return error from form - InsiteFX - 07-24-2020 If the session is logging out you will need to add it again, you can up the session timeout so that this does not happen. sessionExpiration = 0 Will destroy the session on web browser exit. seconds -----------------------------| minutes -----------------------| | hours -------------------| | | days -----------| | | | years ------| | | | | y d h m s time () + (20 * 365 * 24 * 60 * 60) RE: return error from form - 68thorby68 - 07-24-2020 (07-24-2020, 08:06 AM)InsiteFX Wrote: If the session is logging out you will need to add it again, you can up the session timeoutMany thnaks, but I was more concerned why there was an infinite loop when trying to redirect to the login page? Code: if($uri->getPath!='login' ) RE: return error from form - InsiteFX - 07-24-2020 Only thing I can think of would be your redirect. Check your if user_id it might not be removed. |