Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
该网站完全使用 HTTPS,没有使用 HTTP 的页面。我想为 cookie 设置安全和 httponly 标志。除了对每个 cookie 都这样做,有没有办法在全局范围内对所有 cookie 这样做?如标题所述,我使用 PHP 5.3 和 Apache。
请注意,我知道会话 Cookie 是可能的,但我需要它用于网站中的所有 cookie。
非常感谢。
简而言之,没有。
您可以管理此问题的唯一方法是拥有一个辅助函数:
function setSecureCookie($name, $val = '', $exp = 0, $path = '', $domain = '') { return setcookie($name, $val, $exp, $path, $domain, true, true); }