Check Coockies created by the server not by the user

I was creating a login system but I ran into an issue. I have to use PHP COOKIES. A cookie is created when a user enters the correct username and password. “user=22” or “user=23” etc. But a user can go to the console panel and create this cookie themselves with document.cookie.

isset($_COOKIE[“user”]) returns true even if the cookie is created by user in console panel. So, I have to check the cookies created by the server. Is there a way to do it? Let me know if there is a better way to fix this problem 🙂