Completely off-topic, but it could be handy to have a small checklist on cookies. After all, this is what you explicitely asked for:
-
To change the value for a cookie, send out a cookie with the same name and path, and with the new value
- You can pass it an expiration date, at what time the browser will forget about the cookie. If you don't, the cookie will expire as soon as the browser is closed.
- To delete a cookie, send out a cookie with the same name and path, with any value you like, and with the expiration date somewhere in the past.
If you find you can't get rid of a cookie, it's likely that that cookie got set with a different path. There's no way on the server side, to figure out what path a cookie was set valid for. In fact, if you set a cookie with the same name for a different path, you'll end up with two cookies of the same name. It could be you only see the last cookie sent, depending on what cookie library you use. I don't think there are any rules on what order the browser will send them to the server, so I would never rely on it.