Whats the recommended way to set httponly and secure flags on the PHPSESSID cookie?
I found http://www.php.net/manual/en/session.configuration.php#ini.session.cookie
Using .htaccess for this purpose just slows down your application.
I think its better to add this snippet in your main config file ( example config.php ) or main include file ( example global.php )
// Prevents javascript XSS attacks aimed to steal the session ID
ini_set('session.cookie_httponly', 1);
// Prevent Session ID from being passed through URLs
ini_set('session.use_only_cookies', 1);
If you are using https:// instead of http:// , then also do
// Uses a secure connection (HTTPS)
ini_set('session.cookie_secure', 1);
This method is also suitable for thos who dont have access to php.ini