How to determine if a function has set a cookie?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Collins

    #1

    How to determine if a function has set a cookie?


    I'm using PHPUnit to test some PHP scripts and I'd like to know if there
    is a means of checking which cookies have been set by setcookie() in a
    function under test.

    --
    Ian Collins.
  • Rik

    #2
    Re: How to determine if a function has set a cookie?

    Ian Collins wrote:
    I'm using PHPUnit to test some PHP scripts and I'd like to know if there
    is a means of checking which cookies have been set by setcookie() in a
    function under test.
    There is _no_ way to test which cookies have explicitly been set by
    setcookie(). A cookie is a cookie, and can be set a lot of different ways.
    You can check however which cookies this particular script tries to set:
    <http://www.php.net/headers_list>.

    And offcourse, you can monitor changes in the $_COOKIE array after a new
    pagerequest.
    --
    Rik Wasmus

    Comment

    • Ian Collins

      #3
      Re: How to determine if a function has set a cookie?

      Rik wrote:
      Ian Collins wrote:
      >
      >I'm using PHPUnit to test some PHP scripts and I'd like to know if there
      >is a means of checking which cookies have been set by setcookie() in a
      >function under test.
      >
      >
      There is _no_ way to test which cookies have explicitly been set by
      setcookie(). A cookie is a cookie, and can be set a lot of different
      ways. You can check however which cookies this particular script tries
      to set: <http://www.php.net/headers_list>.
      >
      Thanks Rik, that's exactly what I'm after.

      --
      Ian Collins.

      Comment

      Working...