Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Session error #168

Closed
Jbaukens opened this issue Apr 23, 2016 · 16 comments
Closed

Session error #168

Jbaukens opened this issue Apr 23, 2016 · 16 comments

Comments

@Jbaukens
Copy link
Contributor

Hello nothing really changed since days exept for my vps hosting compagny and i suddently experience huge error logs file with the same error, sessionID might change, if i install using vestacp i have no problems once installed on a cpanelwhm server i get this error alot alot alot what can i do

[06-Mar-2016 03:49:28 Europe/Brussels] PHP Fatal error: Uncaught exception 'Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'userID' cannot be null

Query-Code:REPLACE INTO uni1_session SET
sessionID = 1ab21af39d2ebcb7e81fedcf18028e58,
userID = ,
lastonline = 1457232568,
userIP = 80.200.59.250;' in /home/xterium/public_html/includes/classes/Database.class.php:109
Stack trace:
#0 /home/xterium/public_html/includes/classes/Database.class.php(152): Database->_query('REPLACE INTO %%...', Array, 'replace')
#1 /home/xterium/public_html/includes/classes/Session.class.php(229): Database->replace('REPLACE INTO %%...', Array)
#2 [internal function]: Session->save()
#3 {main}

thrown in /home/xterium/public_html/includes/classes/Database.class.php on line 109

@OzanKurt
Copy link
Contributor

Please change table engine to MYISAM

@jkroepke
Copy link
Owner

Why he should do this?

@jkroepke
Copy link
Owner

Do you have some customized login code?

@OzanKurt
Copy link
Contributor

Its about INNODB binding the userID field with the id in users table, that's the reason you cant assign null to userID. In MYISAM there is no such thing.

@jkroepke
Copy link
Owner

Thats right. But its an error in 2moons somewhere that tryinig to save an session without an userId

@OzanKurt
Copy link
Contributor

The we should log the actions.

@Jbaukens
Copy link
Contributor Author

Jbaukens commented Apr 24, 2016

Hello i have a custom login page
There should be no real problems with the file since with any other server panel than cpanel and whm i dont have this, i am using 10.0.24-MariaDB

PS: tested with MYISAM instead of MEMORY, i didnt changed the problem still exist
All i do is download/upload and export/import to a dedicated server instead of vps but that should not cause any trouble, i mean its the first time i use a cms and when i change server, i got a problem so its difficult to find the problems

Regards

@jkroepke
Copy link
Owner

Maybe you can add a $session->delete(); before https://github.com/jkroepke/2Moons/blob/master/includes/common.php#L122 ?

@Jbaukens
Copy link
Contributor Author

Hello jan i was able to reproduce the error, i have some ajax files that is working when you are logged in but that trigger that error when you are not logged in, so i maybe things its some one or a bot visiting those page and refreshing non stop as i was able to add my own session id and error in the logs,

Anyway, is there a way to check if a user is really logged in ?

That is my default ajax code at the begin of the file

define('MODE', 'BANNER');
define('ROOT_PATH', str_replace('', '/',dirname(FILE)).'/');
set_include_path(ROOT_PATH);
require 'includes/common.php';

$session = Session::load();
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$USER = Database::get()->selectSingle($sql, array(
':userId' => $session->userId
));

if(empty($USER))
exit();

@jkroepke
Copy link
Owner

Somethink like

    $session    = Session::load();

    if(!$session->isValidSession())
    {
        $session->delete();
        HTTP::redirectTo('index.php?code=3');
    }

@jkroepke
Copy link
Owner

The concept of the session code is bad.

@Jbaukens
Copy link
Contributor Author

Jbaukens commented Apr 24, 2016

Really weird my game doesnt generate that error on VESTACP as i just tried it again but i really want to use cpanel/whm
with your solution the error changed in a error with no session id and no userID
Also funny thing is when i deploy nginx on cpanel it jump from account to account

[24-Apr-2016 17:42:34 Europe/Berlin] PHP Fatal error: Uncaught exception 'Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'userID' cannot be null



Query-Code:REPLACE INTO uni1_session SET
sessionID = ,
userID = ,
lastonline = 1461512554,
userIP = 181.167.35.12;' in /home/xterium/public_html/includes/classes/Database.class.php:109
Stack trace:
#0 /home/xterium/public_html/includes/classes/Database.class.php(152): Database->_query('REPLACE INTO %%...', Array, 'replace')
#1 /home/xterium/public_html/includes/classes/Session.class.php(230): Database->replace('REPLACE INTO %%...', Array)
#2 [internal function]: Session->save()
#3 {main}
thrown in /home/xterium/public_html/includes/classes/Database.class.php on line 109

@jkroepke
Copy link
Owner

But i looks better for me.

With this, I can fix it in 2moons.

@jkroepke
Copy link
Owner

071234b

@Jbaukens
Copy link
Contributor Author

Hello jan, i just want to thanks you :)
This indeed fixed my problems under cpanel/whm i have no problem anymore ?
You maybe know why under VESTACP i dont have this ? Do they maybe report less errors ?
Anyway thanks alot, if you want to send me your paypal email i will make a donation you really did great job all those years

@jkroepke
Copy link
Owner

Hi,

your are welcome.

Anyway, i don't have any idea. Did you have any errors with CPanel? (Maybe Force override the error log level/path). Maybe CPanel has less strict MySQL options.

Anyway, you don't need to make a money donation. If you push your fixes to GitHub, it would the enough.

jkroepke pushed a commit that referenced this issue Aug 18, 2019
#150 fix for phalanx overview activity + recycle being shown
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants