【问题标题】:turning on https flag for cookie打开 cookie 的 https 标志
【发布时间】:2012-10-19 05:24:21
【问题描述】:

所以我使用的是 php 4 中的旧版应用程序。 我正在尝试设置 httponly 标志和安全标志。

这是我的代码:

header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expireSeconds."; sessionID=".$sessId.";path=".$path."; domain=".$domain."; httponly; secure");

安全标志已设置,但 httponly 未设置。

会不会是因为网址使用了https协议?

编辑: 此外,过期字段是否需要几秒钟。现在, $expireSeconds=14400; 如果不期望秒作为参数,我该如何修改代码以纠正此问题。

【问题讨论】:

    标签: php html cookies setcookie cookie-httponly


    【解决方案1】:

    当有setcookie() 可用时,你为什么要通过header() 来做呢?该函数在 PHP4 中可用。

    setcookie($cookieName, $sessID, $expireSeconds, $path, $domain, true, true);
                                                                    ^--secure
                                                                          ^--http 
    

    【讨论】:

    • httponly 标志在 php 4 的 setcookie 函数中不可用
    猜你喜欢
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    • 2023-04-08
    • 2011-04-02
    • 2020-03-27
    相关资源
    最近更新 更多