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

Error with database sessions in remote database - Undefined property: stdClass::$ci_session_lock. #6213

Open
drkNsubuga opened this issue May 22, 2023 · 1 comment

Comments

@drkNsubuga
Copy link

drkNsubuga commented May 22, 2023

Sessions fail with the remote database only

I configured the session options in application/config.php like so:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_secure']	= TRUE;
$config['cookie_httponly'] 	= TRUE;

The Issue

This error occurs with the remote database but does not occur with the local database.

Severity: Warning --> Undefined property: stdClass::$ci_session_lock system/libraries/Session/drivers/Session_database_driver.php 409
Severity: Warning --> session_start(): Failed to read session data: user (path: ****) system/libraries/Session/Session.php 137

The Environment

  • Codeigniter 3.1.13
  • PHP 8.0-8.2.6
  • Remote database: Planetscale
  • Local databse: MariaDB 10.4.20
@privatecore
Copy link

@drkNsubuga it's not an error, but warning

https://github.com/bcit-ci/CodeIgniter/blob/develop/system/libraries/Session/drivers/Session_database_driver.php#L409
according to the message, sql query does not return expected result (null):

GET_LOCK(str,timeout)

Returns 1 if the lock was obtained successfully, 0 if the attempt timed out (for example, because another client has previously locked the name), or NULL if an error occurred (such as running out of memory or the thread was killed with mysqladmin kill).

also, check your db config:
https://codeigniter.com/userguide3/libraries/sessions.html#database-driver

You must have the Query Builder enabled.
You can NOT use a persistent connection.
You can NOT use a connection with the cache_on setting enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants