MyBB Community Forums

Full Version: PHP 8.4 mybb error when logging in
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There seems to be an "Authorization code mismatch. Are you accessing this function correctly? Please go back and try again." error when logging in php8.4

This seems to happen the very first forum end login after an installation.
sorry for previous post , and I checked more and problem was for me from $_COOKIE variable and not return correct value , so I fixed problem like this.

IN inc/class_session.php Line 68 I changed
$sid = $db->escape_string($mybb->cookies['sid']);
with
			$cookies = explode('; ', $_SERVER['HTTP_COOKIE']);
			$mycookie = [];
			foreach($cookies as $cookie) {
			$kv = explode('=', $cookie);
			$mycookie[$kv[0]] = $kv[1];
			}
			$sid = $db->escape_string($mycookie['sid']);
I did not found why $_COOKIE returned wrong value , but this way we can get current value , And the problem is solved.

I hope this helps.
Hi Mostafa, so I'm correct to understand that you were able to replicate this issue and that you found a possible solution for it to not happen in the first login after installing ?

Please let us know so we can push the issue to GitHub.

Regards.
(2024-12-31, 02:58 AM)Omar G. Wrote: [ -> ]Hi Mostafa, so I'm correct to understand that you were able to replicate this issue and that you found a possible solution for it to not happen in the first login after installing ?

Please let us know so we can push the issue to GitHub.

Regards.

yes , this is solve the problem .es that code solve the problem. and prevent to extra session entry for one login and login without error.
See if the same happens after removing lines with E_STRICT: https://github.com/mybb/mybb/issues/4860

If an error is displayed, cookies may not be set correctly.
(2024-12-31, 12:18 PM)Devilshakerz Wrote: [ -> ]See if the same happens after removing lines with E_STRICT: https://github.com/mybb/mybb/issues/4860

If an error is displayed, cookies may not be set correctly.

yes  E_STRICT is deprecated , Weird thing  , I don't know how I didn't notice. Big Grin
I found other solution In some cases , this problem is from browser , if you delete your website data and cookies one time , then you can login without problem and error.
for example in firefox with click on "Clear cookies and site data...":
but if this not fix problem , you can use change code that I mentioned at the top post.
anyway , problem is mybb has problem to read sid cookie and you can fix this with differents way, depend on your conditions.

[attachment=47570]