CodeIgniter Forums
How can i move force_https in before filter - 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: How can i move force_https in before filter (/showthread.php?tid=76920)



How can i move force_https in before filter - cvlancvlan - 07-03-2020

How can i move force_https in before filter ? I wan't remove this force_https from system/Controller.php and i want add in filter.
I created an login sistem in filters where i recive informations from $_POST. In this case the redirect to https it will be done after i checked some informations from $_POST. I want first the redirect to be done.

I tried this but didn't work. app/GlobalFilter.php

PHP Code:
<?php namespace App\Filters;
use 
CodeIgniter\Filters\FilterInterface;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface

class 
GlobalFilter implements FilterInterface {
    
    protected 
$session;
    
    public function 
before(RequestInterface $requestResponseInterface $response) {

        
force_https(31536000$request$response);
    
   
    
}
    
    public function 
after(RequestInterface $requestResponseInterface $response) {
       
    
}
   


How can i override system/Controller.php ?
I tried copy this system/Controller.php in app/Controller.php folder but didn't work for me