So I did some digging and did not find a satisfactory answer to my question concerning the PHP setcookie()
parameter secure
. The documentation says the following:
Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. When set to true, the cookie will only be set if a secure connection exists. On the server-side, it's on the programmer to send this kind of cookie only on secure connection (e.g. with respect to
$_SERVER["HTTPS"]
).
What I do not understand is the last part. What is meant by "On the server-side[...]"?
I did some testing and on my local machine, cookies are set even without https when secure
is set to true
. On my webserver, they are not. So does the browser consider localhost to be secure even without https?
I both set secure
to true
and check $_SERVER["HTTPS"]
to be on the safe side, but I would like to know what exactly secure
does, or rather what it does not do.
Best wishes and thanks!