Cookies are client-controlled input. Check for the key and escape a value before putting it into HTML.
<?php
$value = $_COOKIE['Plus2netCookie'] ?? '';
if ($value !== '') {
echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
?>Current example first; the detailed tutorial examples below are retained for additional learning and comparison.
echo "<b> Welcome </b><i>" .@$_COOKIE["Plus2netCookie"] . "</i>";
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.