Archive for August 11th, 2006

httpOnly cookies in PHP

Ilia, one of the PHP developers, has included a patch by Scott MacVicar into CVS for PHP 5.2 that allows you to set a httpOnly cookie instead of a normal cookie. A httpOnly cookie allows you to set a cookie that isn't accessible via Javascript, and so removes the possibility of some nefarious code to try and read your cookie.

This can be enabled in PHP 5.2. by passing TRUE as the 7th paramenter in setcookie() and setrawcookie(). In versions below 5.2, you can set this by passing an additional header.

PHP:
  1. header("Set-Cookie: hidden=value; httpOnly");

Add comment August 11th, 2006


Calendar

August 2006
M T W T F S S
« Jul   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031  

Posts by Month

Posts by Category