php - Prevent manipulation cookie on client side -
i know cookie work string , not accept array... far
creating , reading cookie:
setcookie( 'name' , 'my name foo' ); echo $_cookie['name']; // output name foo
if user change cookie name to: name[]
changes cookie name
in array , error: array string conversion.
1) how can prevent kind of safe handling of cookies?
2) if work class of cookie, method should return strings?
you have 2 choices:
use session variables instead of cookies.
validate cookes when use them. 1 part of encrypting cookie value, , prepending private key before value. script can decrypt cookie , test whether begins private key. can test whether user renamed cookie array:
if (is_string($_cookie['name'])) { ... }
Comments
Post a Comment