为https打开https标志

时间:2012-10-29 20:47:08

标签: php html cookies setcookie cookie-httponly

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

这是我的代码:

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

安全标志设置为开,但httponly不是。

可能因为URL使用https协议吗?

编辑: 此外,过期字段需要几秒钟。马上, $ expireSeconds = 14400; 如果不将秒作为参数,我该如何修改代码来纠正这个问题。

1 个答案:

答案 0 :(得分:0)

为什么在setcookie()可用时通过header()进行此操作?此功能在PHP4中可用。

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