Server Error Log entries due to addition of code to session.php file

AndyB

Well-known member
I'm getting the following Server Error Logs:

pic001.webp

This is due to me adding the following code to the session.php file:

PHP:
$my_style = $_COOKIE["style"];

What would be the best way to avoid getting the server error logs? My code is working perfectly.

Thank you.
 
PHP:
$my_style = XenForo_Application::get('options')->defaultStyleId;

if(isset($_COOKIE['style'])) {
  $my_style = $_COOKIE['style'];
}

Its a good rule of thumb to always verify an index exists before accessing it.
 
Hi King Kovifor,

Thank you so much for helping.

It turned out that replacing the line:

$my_style = $_COOKIE["style"];

with

$my_style = $request->getCookie('style');

solved my problem with the server error logs.
 
Top Bottom