Skip to content

Commit

Permalink
merged branch Seldaek/clearcookie (PR #1889)
Browse files Browse the repository at this point in the history
Commits
-------

908a7a3 [HttpFoundation] Fix bug in clearCookie/removeCookie not clearing cookies set with a default '/' path, unless it was explicitly specified

Discussion
----------

[HttpFoundation] Fix bug in clearCookie/removeCookie not clearing cookies

[HttpFoundation] Fix bug in clearCookie/removeCookie not clearing cookies set with a default '/' path, unless it was explicitly specified

---------------------------------------------------------------------------

by Seldaek at 2011/08/02 10:31:44 -0700

The reason is that Cookie::__construct defaults to '/' btw, so if you don't specify it, and then call clearCookie without specifying again, the paths don't match.

---------------------------------------------------------------------------

by Koc at 2011/08/07 00:06:13 -0700

I think that correctrly use base path. Is it possible?

For example we have 2 apps
* site.com/app1/index.php
* site.com/app2/index.php
and app2 will remove cookies of app1

---------------------------------------------------------------------------

by Seldaek at 2011/08/07 02:58:10 -0700

IMO if people want that they should specify the path manually, by default cookies are always set for the entire host and I think it should stay like that.

---------------------------------------------------------------------------

by Koc at 2011/08/07 04:26:47 -0700

It is hard to specify path manually everywhere when set/remove cookies.

---------------------------------------------------------------------------

by Seldaek at 2011/09/27 07:01:43 -0700

@fabpot: ping? You said this was ok, but it was never merged.
  • Loading branch information
fabpot committed Sep 28, 2011
2 parents 94940fe + 908a7a3 commit ffdd667
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Expand Up @@ -139,7 +139,7 @@ public function setCookie(Cookie $cookie)
*
* @api
*/
public function removeCookie($name, $path = null, $domain = null)
public function removeCookie($name, $path = '/', $domain = null)
{
unset($this->cookies[$domain][$path][$name]);

Expand Down Expand Up @@ -195,7 +195,7 @@ public function getCookies($format = self::COOKIES_FLAT)
*
* @api
*/
public function clearCookie($name, $path = null, $domain = null)
public function clearCookie($name, $path = '/', $domain = null)
{
$this->setCookie(new Cookie($name, null, 1, $path, $domain));
}
Expand Down

0 comments on commit ffdd667

Please sign in to comment.