With regards to security and convenience which cookies are better the PHP ones or the Javascript ones?
HTTP Cookies are not a feature of PHP, nor a feature of Javascript : those are just programming languages that allow a developper to manipulate them. The biggest difference between JS and PHP is that : Javascript runs on the client side. PHP runs on the server side.
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.
JavaScript can create, read, and delete cookies with the document. cookie property.
They are the same ones, in both cases the cookie is sent to the browser, stored there and the browser send it back to you every request until it expires or is deleted.
For that reason, you should never use cookie for security as your question implies nor for any data which you consider important to keep unaltered by the end user.
There are five things to always remember when you use cookie:
1 - you can not trust its content
2 - you can not assume it will still be there on the next request
3 - you can not trust its content
4 - you can not assume the user never visited before if it's not there
5 - you can not trust its content
If you get that, accessing cookie from php or javascript is simply a question of what's more convenient to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With