Javascript cookies vs php cookies

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

But cookies are still the same : they are defined as a standard — see RFC 2965.

Still, note that modern browsers implement cookies that are not accessible from Javascript *(see the `httponly` option of [`setcookie`][3])* — which means that, depending on the browser, and the way a cookie was set, it might not be accessible from Javascript.

This is a security measure — and is not a difference between “js cookies” and “php cookies” : it’s just a property of some cookies.

Leave a Comment