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

AndyB

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

pic001.jpg

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.
 

Jeremy

Well-known member
#2
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.
 

AndyB

Well-known member
#3
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