Home>Article>Backend Development> How to set cookie_httponly in php
How to set httponly in php: First open the php configuration file "php.ini"; then find the "session.cookie_httponly" setting item; then press "i" to put "vi" into edit mode and change the value Set to "1"; finally restart "php-fpm".
Recommended: "PHP Tutorial"
php.ini settings cookie_httponly
Method:
Find the path to the php configuration file through the php --ini command
# php --ini
Open the php configuration file php.ini
# cd /usr/local/php7/lib # vi php.ini
Find the session.cookie_httponly = setting item, press i to enter vi into edit mode, and set the value to 1.
session.cookie_httponly = 1
Press the Esc key and enter: wq to save and exit the vi editor.
:wq
Restart php-fpm, find the php-fpm process number through ps, and then restart php-fpm
# ps -ef | grep php-fpm # kill -USR2 查询到的进程号
Through the debug mode of the chrome browser, I can see that httponly is not checked, but the cookie cannot be obtained through js. The settings have taken effect.
Notes
In order to keep the site from stopping, please restart php-fpm smoothly.
The above is the detailed content of How to set cookie_httponly in php. For more information, please follow other related articles on the PHP Chinese website!