Reputation: 68074
Is it possible to create a cookie with javascript and then read it with PHP? And What about the other way around?
Upvotes: 2
Views: 926
Reputation: 356
There is a new parameter in the php "setcookie" function (from php 5.2.0) that you should be aware of: it is called "httponly". If set to true (by you), javascript won't be allowed to read the cookie's content. It helps prevent XSS attacks. More info on: http://php.net/manual/en/function.setcookie.php
Upvotes: 2
Reputation: 12673
Yes you can both set and read cookies on either side.
On the javascript side you'll need to parse the document.cookie
variable, but there are plenty of libs to do that (jQuery has a plugin to do so).
Upvotes: 2