Welcome Guest, Not a member yet? Register   Sign In
Cookie Path – "default" setting overrides explicit "/"
#1

Good day,

situation is this:
 - have a default cookie path of /path, because ci_session should not be accessible outside /path
 - need to set a cookie from CI with path of "/" – this cookie needs to be accessible site-wide, for another web application to work
 - using CI's response->setCookie().. to set this cookie, specifying '/' as cookie path
 - System\HTTP\Response:ConfusedetCookie overrides cookie path even if it is explicitly set to '/' by the caller. 

I think this is not how it should behave. I suggest CI should only use default path when path  is not set (or set to null) by caller.

Am I on the wrong track here?

code snippet from: CI4 4.0.0 alpha 4 Response class:
public function setCookie(
  $name,
  $value = '',
  $expire = '',
  $domain = '',
  $path = '/',
 
$prefix = '',
  $secure = false,
  $httponly = false
)

{
(...)
if ($path === '/' && $this->cookiePath !== '/')
{
  $path = $this->cookiePath;
}


How I think it should be:
public function setCookie(
  $name,
  $value '',
  $expire '',
  $domain '',
  $path null,
 
 $prefix '',
  $secure false,
  $httponly false
)

{
(...)
if (null === $path)
{
  $path $this->cookiePath;
}


(While debugging the situation, I found a typo in the PHPDoc of the function, on line 810Smile
* Accepts an arbitrary number of binds (up to 7) or an associateive
Reply




Theme © iAndrew 2016 - Forum software by © MyBB