Cookies

Hello

I currently have a script that uses cookies for validation e.g

UPDATE data WHERE id = $_COOKIE[‘id’]

$_COOKIE[‘id’] being the logged in users id.

Is it possible for a user to simply change the id in their cookies and insert the data using another id?
If so, how can I prevent this?

Yes it is possible for people to alter values of cookies because cookies are basically a small text file stored on the users pc.

I normally steer away from using cookies, at least for mandatory functionality, because you would have to code a plan B for users with with cookies disabled. For something like what you are using cookies for in this case, storing the data in a session variable is probably better and definitely more secure.

Hi thank you for your response. So on the other hand this would be 100% secure?
UPDATE data WHERE id = $_SESSION[‘id’]

I don’t see what your update statement is trying to do. What is data - a variable, db table or something else?

Hi its just an exampke

UPDATE table WHERE id = $session SET post=mysql_real_escape_string($post)