When trying to call the method
CakeSession->destroy()
I’m getting this error:
Undefined index: userAgent
The Stack Trace is as follows:
lib\Cake\Model\Datasource\CakeSession.php : 332
lib\Cake\Model\Datasource\CakeSession.php : 632
lib\Cake\Model\Datasource\CakeSession.php : 192
lib\Cake\Model\Datasource\CakeSession.php : 438
lib\Cake\Model\Datasource\CakeSession.php : 427
I’ve followed it down to to the method
CakeSession->_validAgentAndTime()
and that index is really missing — anyhow, I got no idea how to get it there. It only seems to occur when running PHPUnit Tests.
Sometimes, if I run another test after this error and to back, it works once and then keeps failing again.
I’m using CakePHP 2.2.3 and PHPUnit 3.7.10 btw.
Older browsers and bespoke applications may provide strange or no UserAgent, but you can disable the UserAgent aspect of CakePHP in the app/core/config.php file:
If you want to keep the UserAgent intact for your tests, you can use the below to debug …
env(‘HTTP_USER_AGENT’);