doudu3961 2016-06-21 16:30
浏览 292

如何设置HTTP HTTPOnly和安全属性?

How to check cookies HTTPOnly and secure attribute?

I have an issue with cookies not containing the HTTPOnly and secure attribute.

So I use this code to solve it.

<?php
$name_cookie = '1';
$value_cookie = '2';
$expirationTime_cookie = 0;    // Session cookie.
$path_cookie = '/';
$domain_cookie = 'example.com';
$isSecure_cookie = true;
$isHttpOnly_cookie = true;
setcookie($name_cookie, $value_cookie, $expirationTime_cookie, $path_cookie, $domain_cookie, $isSecure_cookie, $isHttpOnly_cookie);
?>

I want to know, if I use the above code, will the issue with cookies not containing the HTTPOnly and secure attributes, be solved or not?

  • 写回答

1条回答 默认 最新

  • douxiegan6468 2016-11-04 07:38
    关注

    At webserver config:

    php_flag session.cookie_httponly on
    php_flag session.cookie_secure on
    

    or in your PHP code, above cookie use:

    ini_set( 'session.cookie_httponly', 1 );
    ini_set( 'session.cookie_secure', 1 );
    
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)