Welcome Guest, Not a member yet? Register   Sign In
codeigniter 4.04 session destroy automatically
#1

(This post was last modified: 03-04-2021, 01:43 AM by shashi.)

Dear All,

Hope all are doing well !!!

I am using CI 4.0.4 - XAMPP CONTROL 3.2.4

I AM USING CI 4.0.4 FOR MY ONGOING LIVE PROJECT

MY WEBSITE URL : 172.168.2.5/shashi/public/   , i am not using spark


the above url is run in my local office

there are 10-15 users accessing above IP URL in local office

Problem is : all users complaining that session is expire suddenly - sometime its works for 3-4 hours , but some time after login of 5 min only session get destroy .

There are pages which have 30-35 fields - so my users put all fields and when they click on submit button and session is expire and go to login page. which become very irritating to login again and Fill all fields .

This happening daily and make my project going in worst phase .


Below is my App.php , FILTERS ( LOGIN SESSION ) AND ROUTE CODE :


 Session :


PHP Code:
public $sessionDriver            'CodeIgniter\Session\Handlers\FileHandler';
public 
$sessionCookieName        'shashiviewinside';
public 
$sessionExpiration        0;
public 
$sessionSavePath          WRITEPATH 'session';
public 
$sessionMatchIP           false;
public 
$sessionTimeToUpdate      300;
public 
$sessionRegenerateDestroy true

Cookies :

PHP Code:
public $cookiePrefix  '';
public 
$cookieDomain  '';
public 
$cookiePath    '/';
public 
$cookieSecure  false;
public 
$cookieHTTPOnly false

ROUTE :


PHP Code:
$routes->group('sh',['filter' => 'auth'], function($routes) {
   $routes->get('projects''Projects::index',['namespace' => 'App\Controllers\Sh']);
   $routes->add('projects/add''Projects::addproj',['namespace' => 'App\Controllers\Sh']);
   $routes->add('projects/edit/(:num)''Projects::editproj/$1',['namespace' => 'App\Controllers\Sh']);
   $routes->add('projects/view/(:num)''Projects::viewproj/$1',['namespace' => 'App\Controllers\Sh']);
   $routes->add('projects/update''Projects::updateproj',['namespace' => 'App\Controllers\Sh']);
}); 


filter => auth.php


PHP Code:
<?php namespace App\Filters;

use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
CodeIgniter\HTTP\URI;
use 
CodeIgniter\Filters\FilterInterface;
 

class 
Auth implements FilterInterface
{
protected 
$uri;
protected 
$session;

   public function before(RequestInterface $request$arguments null)
   
      $this->session = \Config\Services::session();
      $this->session->start();
      $isLoggedIn $this->session->get('isLoggedIn');
      $sess_id $this->session->has('uid');
  
      
if (empty($sess_id) AND $isLoggedIn != 'shas@'.$sess_id 
      {  
        $this
->session->setFlashdata('error_message''Session Expired !!!');
        $logoutlink =  site_url().'login';
        return redirect()->to($logoutlink);
       
   }


    public function after(RequestInterface $requestResponseInterface $response$arguments null)
    {
        //echo "AFTER";
    }



Let me know what i am doing wrong .

some pages has Ajax call too  - but  session get expire from page where ajax is not there - in short all page with ajax or without ajax  get session destroy .



Thanks
Shashi
Reply


Messages In This Thread
codeigniter 4.04 session destroy automatically - by shashi - 03-04-2021, 01:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB