Not setting cookies does not directly pose a security risk, but in certain scenarios, it may negatively impact both the user experience and security.
First, if no cookie is set after a user logs in, the user will need to log in again every time they open the page – which increases the complexity and time required for the user's actions and diminishes the overall user experience. Additionally, if a user forgets to log out or close their browser, account security cannot be effectively safeguarded.
Second, in certain scenarios where cookies are used to store authentication credentials or other private data, not setting cookies could increase the risk of data leakage. For example, if a website displays sensitive information—such as a phone number—directly to an unauthenticated user, this information will be visible in the user's browser without authentication, thereby raising the risk of data leakage.
Therefore, when it is necessary to protect user account security, enhance the user experience, or prevent information leakage, setting up cookies is a necessary approach. However, when configuring cookies, it is also important to safeguard user privacy and mitigate security risks such as cookie hijacking.