diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php
index 688f55aa0cb..9dc3f9b3780 100644
--- a/htdocs/core/class/html.formmargin.class.php
+++ b/htdocs/core/class/html.formmargin.class.php
@@ -227,7 +227,7 @@ class FormMargin
} elseif (empty($reshook)) {
if (getDolGlobalString('MARGIN_ADD_SHOWHIDE_BUTTON')) {
print $langs->trans('ShowMarginInfos') . ' ';
- $hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']); // Clean cookie
+ $hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ?? ''; // Clean cookie
print '' . img_picto($langs->trans("Disabled"), 'switch_off') . '';
print '' . img_picto($langs->trans("Enabled"), 'switch_on') . '';