Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: BaseHandler.php error #6425

Closed
kseok2307 opened this issue Aug 26, 2022 · 8 comments
Closed

Bug: BaseHandler.php error #6425

kseok2307 opened this issue Aug 26, 2022 · 8 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@kseok2307
Copy link

kseok2307 commented Aug 26, 2022

PHP Version

8.0, 8.1

CodeIgniter4 Version

CodeIgniter 4.2.4

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

MySQL 5.7

What happened?

When trying to handle mysql session
An error occurred in BaseHandler.php file

ini_set function Error correction is required.

Steps to Reproduce

App.php

public $sessionDriver = 'CodeIgniter\Session\Handlers\DatabaseHandler';
public $sessionSavePath = 'ci_sessions';

Expected Output

Fatal error
Uncaught ErrorException: ini_set(): Session ini settings cannot be changed when a session is active in /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/BaseHandler.php:162
Stack trace:

Anything else?

No response

@kseok2307 kseok2307 added the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 26, 2022
@ddevsr
Copy link
Collaborator

ddevsr commented Aug 26, 2022

Give your code controller

@kseok2307
Copy link
Author

kseok2307 commented Aug 26, 2022

Give your code controller

Thanks for your reply.

The file session handler works, but the session database handling throws an error.

$sessionData = array(
'emp_id' => $row['emp_id']
);

$this->Session->set($sessionData );

@DhPandya
Copy link
Contributor

DhPandya commented Aug 26, 2022

@kseok2307
Share your code that is responsible to initialize the $this->Session.
And if possible then share your whole controller code.

@kseok2307
Copy link
Author

kseok2307 commented Aug 26, 2022

I got an error trying to handle the session database.
File handling works well in my code.

image

[app\Controllers\LoginController.php]

image

[app\Services\AuthService.php]
=> It's a library file that I made.
image

[vendor\codeigniter4\framework\system\Session\BaseHandler.php]
=> error

Fatal error
Uncaught ErrorException: ini_set(): Session ini settings cannot be changed when a session is active in /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/BaseHandler.php:162
Stack trace:

image

@kenjis
Copy link
Member

kenjis commented Aug 26, 2022

@kseok2307 Please don't use screenshot for your code. We cannot copy & paste it.

@kenjis
Copy link
Member

kenjis commented Aug 26, 2022

Can you show the Stack trace?

Uncaught ErrorException: ini_set(): Session ini settings cannot be changed when a session is active in /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/BaseHandler.php:162
Stack trace:

@kseok2307
Copy link
Author

kseok2307 commented Aug 26, 2022

@kseok2307 Please don't use screenshot for your code. We cannot copy & paste it.

I'm really sorry.
I made a mistake because I am a beginner in writing.
I don't have the current source code. Screenshot is everything.

@kseok2307
Copy link
Author

kseok2307 commented Aug 26, 2022

Can you show the Stack trace?

Uncaught ErrorException: ini_set(): Session ini settings cannot be changed when a session is active in /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/BaseHandler.php:162
Stack trace:

#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler()
#1 /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/BaseHandler.php(179): ini_set()
#2 /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/Database/MySQLiHandler.php(51): CodeIgniter\Session\Handlers\BaseHandler->fail()
#3 /mnt/d/project/vendor/codeigniter4/framework/system/Session/Handlers/DatabaseHandler.php(234): CodeIgniter\Session\Handlers\Database\MySQLiHandler->releaseLock()
#4 [internal function]: CodeIgniter\Session\Handlers\DatabaseHandler->close()
#5 [internal function]: session_write_close()
#6 {main}

Thank you so much for your concern.

I tried this and it was solved.

@int_set('session.save_path',$this->savePath);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

4 participants