I have a cookie that I use in my application. It looks like this:
+-------+-------+-----------------------+-------+----------+ | Name | Value | Domain | Path | Expires | +-------+-------+-----------------------+-------+----------+ | foo | bar | my.domain.tld | / | Session | +-------+-------+-----------------------+-------+----------+
In a section of my script, based on some condition, I am trying to change the value of a cookie. I am using this code:
// overwrite cookie if($condition){ setcookie("foo", "cat", 0, "/", "my.domain.tld"); }
Subsequently, my cookie details are as follows:
+-------+-------+-----------------------+-------+----------+ | Name | Value | Domain | Path | Expires | +-------+-------+-----------------------+-------+----------+ | foo | bar | my.domain.tld | / | Session | | foo | cat | .my.domain.tld | / | Session | +-------+-------+-----------------------+-------+----------+
How come that . added to domain? I want to overwrite an existing cookie.
php cookies setcookie
maček
source share