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:

  1. use session variables instead of cookies.

  2. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -