Home  >  Article  >  Backend Development  >  How to set cookie_httponly in php

How to set cookie_httponly in php

藏色散人
藏色散人Original
2020-07-25 11:11:044453browse

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".

How to set cookie_httponly in php

Recommended: "PHP Tutorial"

php.ini settings cookie_httponly

Method:

Find the path to the php configuration file through the php --ini command

# php --ini

How to set cookie_httponly in php

Open the php configuration file php.ini

# cd /usr/local/php7/lib
 
# vi php.ini

How to set cookie_httponly in php

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

How to set cookie_httponly in php

Press the Esc key and enter: wq to save and exit the vi editor.

:wq

How to set cookie_httponly in php

Restart php-fpm, find the php-fpm process number through ps, and then restart php-fpm

# ps -ef | grep php-fpm
# kill -USR2 查询到的进程号

How to set cookie_httponly in php

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.

How to set cookie_httponly in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn