Welcome Guest, Not a member yet? Register   Sign In
Session problem
#1

hi , i have a problem with session . 
I store session in db as documentation , i dont know why the record in db  after few second are deleted and the filter redirect me to login (correctly).

In my base controller i have :
Code:
    /**
    * Be sure to declare properties for any property fetch you initialized.
    * The creation of dynamic property is deprecated in PHP 8.2.
    */
    protected $session;

    /**
    * Constructor.
    */
    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);

        // Preload any models, libraries, etc, here.

        $this->session = \Config\Services::session();
    }
The filter:

Code:
    public function before(RequestInterface $request, $params = null)
    {
        // if no user is logged in then send them to the login form
        if (!session()->get('user_username'))
        {           
            session()->set('redirect_url', current_url());
           
            return redirect()->to( '/users/login');
        }
    }
Is It  correct ? 
The problem is born when i change   CI_ENVIRONMENT from development to production ...
Reply
#2

(08-28-2023, 07:34 AM)pippuccio76 Wrote: I store session in db as documentation , i dont know why the record in db  after few second are deleted

It should not happen. I don't know why but you did something wrong.
Reply
#3

(08-28-2023, 06:30 PM)kenjis Wrote:
(08-28-2023, 07:34 AM)pippuccio76 Wrote: I store session in db as documentation , i dont know why the record in db  after few second are deleted

It should not happen. I don't know why but you did something wrong.


The problem is that doing the same operation sometimes it logout and sometime not , in this operation by confirm with message  i use flash data :
Code:
    public function attivaRecord($id){

        $documento_arrivo_model = new Documento_arrivoModel();

        session()->set('id_documento_arrivo_attivo',$id);

        if(isset($_SESSION['id_documento_arrivo_attivo'])){

             session()->setFlashdata('gestisciRecordOK', 'Attivazione correttamente effettuata');

             return redirect()->to('/user_Documento_arrivo/lista_completa/');

        }else{

            session()->setFlashdata('gestisciRecordBad', 'Problemi Attivazione');

            return redirect()->to('/user_Documento_arrivo/lista_completa/');

        }

    }


 What could it be ?
Reply
#4

I change from DatabaseHandler to FileHandler it seem it work fine , Why?
which is the process to delete db record or file for session ?
Reply
#5

FileHandler is default mechanism. probably it is being tested more.

If you are interested in finding an error, try placing the debug information d() between calls and logging the log_message() message with SQL queries, other vars.
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#6

Same problem now with Filehandler , how can i debug the reason why session are destroyed ? Maybe server problem ?
Reply
#7

May be. I have never received such an error. Sessions worked through the database and files
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#8

It seems that the problem happens when we use safari on an ipad, instead with chrome (on android) it doesn't happen. What can I do ?
Reply
#9

Add URL demo here. We testing from another browser.
I can assume that you have a strict policy in the browser. and it deletes session cookies
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#10

(This post was last modified: 08-30-2023, 02:25 AM by pippuccio76.)

(08-30-2023, 01:56 AM)ozornick Wrote: Add URL demo here. We testing from another browser.
I can assume that you have a strict policy in the browser. and it deletes session cookies
it is a webapp that work only on intranet . It is a wms webapp for my company . If i have net problem connection and disconnection can cause the problem ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB