Welcome Guest, Not a member yet? Register   Sign In
codeigniter 4 session or cache issue
#7

got almost working fine now.
added header() to controller and added 
Code:
class BaseController extends Controller
{
    /**
     * An array of helpers to be loaded automatically upon
     * class instantiation. These helpers will be available
     * to all other controllers that extend BaseController.
     *
     * @var array
     */
    protected $helpers = ['form', 'url', 'master'];
    protected $session;
    /**
     * Constructor.
     */
    public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
    {
         
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);
        //--------------------------------------------------------------------
        // Preload any models, libraries, etc, here.
        //--------------------------------------------------------------------
        // E.g.:
        $response->noCache();
        //print_r($response->getHeaders());exit;
        $this->session = \Config\Services::session();
        date_default_timezone_set('Asia/Dubai');
        $this->pager = \Config\Services::pager();
    }

to base controller.
still some caching reamining
when is try to get latest messages from user with  getMsgsByCustomer in below function
Code:
public function viewProfile($cID)
    {
      
        $data['states'] = states();
        $cmSerModel = new customerServiceModel;
        if (session('customerData')) {
            $data['customerDetails'] = $cmsrDetails = session('customerData');
            $data['msgs'] = $cmSerModel->getMsgsByCustomer($cmsrDetails['customerID']);
            $page = 'profilePage';
            if (!is_file(APPPATH . '/Views/home/' . $page . '.php')) {
                throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
            }
            $data['title'] = "Customer Profile";
            echo view('home/profilePage', $data);
        } else {
            return redirect()->to('/');
        }
    }
in model
Code:
    public function getMsgsByCustomer($id = '')
    {
   
        $this->asArray();
        $this->where('customerID',$id);
        $query = $this->findAll();
       
      
        return $query;
    }

it still not showing updated messages.
Reply


Messages In This Thread
codeigniter 4 session or cache issue - by adil - 01-09-2021, 05:42 AM
RE: codeigniter 4 session or cache issue - by adil - 01-19-2021, 02:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB