ingeniasoftware / luthier-ci

Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
https://luthier.ingenia.me/ci/en/
MIT License
150 stars 38 forks source link

Simple Auth Session error #21

Closed abmcr closed 5 years ago

abmcr commented 5 years ago

When i try to login i get this error `An uncaught Exception was encountered Type: Error

Message: Call to a member function flashdata() on null

Filename: /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Auth.php

Line Number: 454`

My session if file driver

andersonsalas commented 5 years ago

Hi @abmcr,

Under which circumstances that error occurred? I need to reproduce it here first.

abmcr commented 5 years ago

the error occur when i try to login

andersonsalas commented 5 years ago

It's too strange, this must work out-of-the-box :disappointed:

I've performed some tests and I'm still unable to reproduce the error. Maybe its a problem with your php session storage.

Please provide the following information:

Also, can be useful if you can provide the log of your application when attempting to use the authentication features. To enable the log, set the value $config['log_threshold'] = 4 in your application/config/config.php file.

abmcr commented 5 years ago

I have a MAC OS 10.13.5 PHP 7.2.7 Codeigniter 3.1.9

session.save_path | no value | no value

LOG

INFO - 2018-07-19 09:35:05 --> Config Class Initialized INFO - 2018-07-19 09:35:05 --> Hooks Class Initialized DEBUG - 2018-07-19 09:35:05 --> UTF-8 Support Enabled INFO - 2018-07-19 09:35:05 --> Utf8 Class Initialized INFO - 2018-07-19 09:35:05 --> URI Class Initialized INFO - 2018-07-19 09:35:05 --> Router Class Initialized INFO - 2018-07-19 09:35:05 --> Output Class Initialized INFO - 2018-07-19 09:35:05 --> Security Class Initialized DEBUG - 2018-07-19 09:35:05 --> Global POST, GET and COOKIE data sanitized INFO - 2018-07-19 09:35:05 --> Input Class Initialized INFO - 2018-07-19 09:35:05 --> Language Class Initialized INFO - 2018-07-19 09:35:05 --> Loader Class Initialized INFO - 2018-07-19 09:35:05 --> Controller Class Initialized INFO - 2018-07-19 09:35:05 --> Helper loaded: url_helper ERROR - 2018-07-19 09:35:05 --> Severity: Notice --> Undefined property: SimpleAuthController::$session /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Auth.php 391 ERROR - 2018-07-19 09:35:05 --> Severity: error --> Exception: Call to a member function flashdata() on null /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Auth.php 391

in config.php $config['sess_driver'] = 'database'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = NULL; $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE;

andersonsalas commented 5 years ago

Yeah, the session library is not being loaded.

I have also noticed that In your configuration you are using the database session driver instead of the files driver. That means you MUST configure the database connection and set up the table that will be used to store the sessions OR just set it back to files (the original value)

According my log:

INFO - 2018-07-19 20:53:04 --> Config Class Initialized
INFO - 2018-07-19 20:53:04 --> Hooks Class Initialized
DEBUG - 2018-07-19 20:53:04 --> UTF-8 Support Enabled
INFO - 2018-07-19 20:53:04 --> Utf8 Class Initialized
INFO - 2018-07-19 20:53:04 --> URI Class Initialized
DEBUG - 2018-07-19 20:53:04 --> No URI present. Default controller set.
INFO - 2018-07-19 20:53:04 --> Router Class Initialized
INFO - 2018-07-19 20:53:04 --> Output Class Initialized
INFO - 2018-07-19 20:53:04 --> Security Class Initialized
DEBUG - 2018-07-19 20:53:04 --> Global POST, GET and COOKIE data sanitized
INFO - 2018-07-19 20:53:04 --> Input Class Initialized
INFO - 2018-07-19 20:53:04 --> Language Class Initialized
INFO - 2018-07-19 20:53:04 --> Loader Class Initialized
INFO - 2018-07-19 20:53:04 --> Controller Class Initialized
DEBUG - 2018-07-19 20:53:04 --> Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.
INFO - 2018-07-19 20:53:04 --> Session: Class initialized using 'files' driver.
DEBUG - 2018-07-19 20:53:04 --> Config file loaded: C:\Apache\htdocs\luthier-ci-tester\application\config/auth.php
INFO - 2018-07-19 20:53:04 --> Helper loaded: url_helper
INFO - 2018-07-19 20:53:04 --> Final output sent to browser
DEBUG - 2018-07-19 20:53:04 --> Total execution time: 0.1075

The following lines are missing in the yours:

DEBUG - 2018-07-19 20:53:04 --> Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.
INFO - 2018-07-19 20:53:04 --> Session: Class initialized using 'files' driver.
DEBUG - 2018-07-19 20:53:04 --> Config file loaded: C:\Apache\htdocs\luthier-ci-tester\application\config/auth.php

So try to set $config['sess_driver'] = 'files' and check your log again. Another alternative is to autoload the session library

Let me know if your problem got solved.

abmcr commented 5 years ago

OK this solve the problem: i have autoload the session library