CodeIgniter Forums
codeigniter 4.04 session destroy automatically - 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: codeigniter 4.04 session destroy automatically (/showthread.php?tid=78732)

Pages: 1 2


codeigniter 4.04 session destroy automatically - shashi - 03-04-2021

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


RE: codeigniter 4.04 session destroy automatically - InsiteFX - 03-04-2021

Update CodeIgniter to the new 4.1.1


RE: codeigniter 4.04 session destroy automatically - shashi - 03-04-2021

(03-04-2021, 02:16 AM)InsiteFX Wrote: Update CodeIgniter to the new 4.1.1
  
  Smile

  thanks for reply
 
   will do that -- in fact have started - side by side

  but need some months - as i have already many coding as per old php version

  need time

  till then - any solution ???

  n do u think this issue will differently solved in 4.1.1  ???


RE: codeigniter 4.04 session destroy automatically - shashi - 03-04-2021

Any one
Please help me
Do I need to change any php code in above
Specially in my filter for login session check

Also I think

public $sessionExpiration = 0;

Is not working ..I think it's taking default 2 hrs

Setting ...bcz I noticed after 2 hrs my page session timeout

This happen 2 time

But yesterday it's was happened after login in between 5 min only

Very confusing ..please help me

As my data entry team are very angry due to double typing...


RE: codeigniter 4.04 session destroy automatically - InsiteFX - 03-04-2021

There were changes to the session files from 4.0.0 to 4.1.1 that's why I told you to upgrade.


RE: codeigniter 4.04 session destroy automatically - shashi - 03-04-2021

(03-04-2021, 12:22 PM)InsiteFX Wrote: There were changes to the session files from 4.0.0 to 4.1.1 that's why I told you to upgrade.


Thanks

will do same .. and hope my issue solve ... in case not than please see its should be corrected in Future development - as when google i saw many post in google with same issue in earlier version of CI3

4.1.1 using latest php version ? - i think for that i need to update my xampp version too.

will try with updating CI 4.0.5 first
if not then will have to go with 4.1.1 and hope its solved

thanks


RE: codeigniter 4.04 session destroy automatically - paulbalandan - 03-05-2021

session expiration has been specifically fixed after 4.0.4. You have no choice but to update version.


RE: codeigniter 4.04 session destroy automatically - shashi - 03-05-2021

(03-05-2021, 12:38 AM)paulbalandan Wrote: session expiration has been specifically fixed after 4.0.4. You have no choice but to update version.

Okay

Thanks


RE: codeigniter 4.04 session destroy automatically - shashi - 04-17-2021

Dear all,

Hope all are doing great

As said by you guys ..I upgraded my xampp ( php 8.3.0 ) to latest version
And codeignter 4.1.1 to latest version too.

Using windows 7 64 bit..and have change some settings in php.ini and my.cnf

But still I am facing session timeout ... It still automatically session expired  after 5 min and some time after 30min ...

Any one can help me ..in any way like check via anydesk etc...
Or share me his/her login panel with all configuration ...so I will build same

As data operators ( desktop )guys are complaining too much ..and it's affecting my job too

Just adding... My last post at forum.codeigniter was on
03-05-2021.. which I Did via my mobile and I didn't logout ..after so many days infact after months ..when I opened forum I was surprised too see I am still login  means I didn't need to login again... How I can maintain such session ..I need like this ...

Second think I just noticed now is
I opened my CI 4.1.1 s.w in mobile and didn't closed my Firefox browser by quit options...just slide up or in some mobile slide right/left..how we do in mobile to close app

And opend firebox ... I saw session expired message....while other tab where I had opened some.other website ...is still login ..like forum.codeignter is still working without session destroy


Don't know why and what happening ...I am using above setting only ...

I just tested one of my pure php website ...that working perfectly ...it's session doesn't destroy such way

Please help me any one
Thanks


RE: codeigniter 4.04 session destroy automatically - shashi - 04-17-2021

Any one here ....