- For your cookies, see this answer.
- For a native PHP script file (
PHPSESSID , by default), see @richie answer
setcookie() and setrawcookie() functions introduced the httponly parameter in the dark of PHP 5.2.0, which makes it nice and easy. Just set the 7th parameter to true according to the syntax
Function syntax simplified for brevity
setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly ) setrawcookie( $name, $value, $expire, $path, $domain, $secure, $httponly )
Enter NULL for the parameters you want to keep by default. You may also consider setting the secure parameter.
It is also possible to use the older header() function:
header( "Set-Cookie: name=value; httpOnly" );
Cheekysoft Aug 31 '08 at 14:38 2008-08-31 14:38
source share