Menu

#28 Cookies not detected properly.

v2.1.x
open
nobody
Detection (25)
5
2014-07-24
2003-03-22
Anonymous
No

With cookies disabled in IE 6 or Mozilla 1.3, phpSniff
states that Session and Stored cookies are true.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I believe the problem stems from the fact that the author
    expects register_globals to be "on". By default this is now
    set to "off" in php version 4.3 -- and even in earlier versions.
    Thus, this code will not work with register_globals set
    to "off". I'd recommend the author fix his code to work with
    the more secure/default php.ini settings.

     
  • Nobody/Anonymous

    Logged In: NO

    With register_globals set to off, the function _test_cookies()
    in phpSniff.core.php needs to explicitly use $_COOKIES to
    work correctly, as in:

    ...[snip]
    $this->_set_browser('cookies',$_COOKIE['phpSniff_session']
    =='ss'?'true':'false');
    $this->_set_browser('ss_cookies',$_COOKIE
    ['phpSniff_session']=='ss'?'true':'false');
    $this->_set_browser('st_cookies',$_COOKIE['phpSniff_stored']
    =='st'?'true':'false');
    setcookie('phpSniff_stored','');
    [snip]...

     
  • Nobody/Anonymous

    Logged In: NO

    I have set it working by replacing the following lines 458,459
    from phpSniff.core.php:
    $this->_set_browser('ss_cookies',isset($cookies
    ['phpSniff_session'])?'true':'false');
    $this->_set_browser('st_cookies',isset($cookies
    ['phpSniff_stored'])?'true':'false');

    By:
    if(isset($cookies['phpSniff_session']) && $cookies
    ['phpSniff_session'] === 'ss') {$phpSniff_session = true;} else
    {$phpSniff_session = false;}
    if(isset($cookies['phpSniff_stored']) && $cookies
    ['phpSniff_stored'] === 'st') {$phpSniff_stored = true;} else
    {$phpSniff_stored = false;}
    $this->_set_browser('ss_cookies',$phpSniff_session);
    $this->_set_browser('st_cookies',$phpSniff_stored);

    Enjoy!!

     

Log in to post a comment.

MongoDB Logo MongoDB