Explorar o código

merged branch Seldaek/clearcookie (PR #1889)

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.
Fabien Potencier %!s(int64=13) %!d(string=hai) anos
pai
achega
ffdd6670a6
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

+ 2 - 2
src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

@@ -139,7 +139,7 @@ class ResponseHeaderBag extends HeaderBag
      *
      * @api
      */
-    public function removeCookie($name, $path = null, $domain = null)
+    public function removeCookie($name, $path = '/', $domain = null)
     {
         unset($this->cookies[$domain][$path][$name]);
 
@@ -195,7 +195,7 @@ class ResponseHeaderBag extends HeaderBag
      *
      * @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));
     }