There is no built-in security risk in using cookies. Security risks come from the processing of cookie data and data stored in cookies. If, for example, you do something like this:
<h3>Hello, <?php echo $_COOKIE['user']; ?>!</h3>
... then the user can enter arbitrary code on your page (XSS vulnerability). To resolve this security issue, you must properly avoid the cookie data for the HTML context:
<h3>Hello, <?php echo htmlspecialchars($_COOKIE['user']); ?>!</h3>
source share