I'm having a strange issue. In my CakePHP app, I am storing sessions in a database. The problem is, if the user logs in and then exits by simply closing the tab/window without logging out (the /logout link which calls $this->Session>-destroy()) then the next time someone visits the site and tries to login in, the user gets a white screen. If the user logs out properly, everything is fine.
The user can login again if the /logout link is called manually or if I delete records from the session table in the db, or if I set CakePHP debugging to 1. If I switch to different session storage engines, everything works, however it is important that I keep using the db engine.
Since users exit apps by closing the window often, is becoming a bit of a problem. How do I properly handle the undestroyed sessions in this case?
Thanks
Update:
After some testing I've found out that the real cause is not the login, but the function that gets Google account users with Zend Gdata libraries. Here's the code:
App::import('Vendor','Zend Oauth Consumer', array('file' => 'Zend/Oauth/Consumer.php'));
App::import('Vendor','Zend Gdata Gapps', array('file' => 'Zend/Gdata/Gapps.php'));
$CONSUMER_KEY = 'x';
$CONSUMER_SECRET = 'y';
$oauthOptions = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'signatureMethod' => 'HMAC-SHA1',
'consumerKey' => $CONSUMER_KEY,
'consumerSecret' => $CONSUMER_SECRET
);
$consumer = new Zend_Oauth_Consumer($oauthOptions);
$token = new Zend_Oauth_Token_Access();
$httpClient = $token->getHttpClient($oauthOptions);
try {
$client = new Zend_Gdata_Gapps($httpClient,$domain);
$feed = $client->retrieveAllUsers(); //this line causes the white screen
$_SESSION['googleUsers'] = array();
foreach ($feed as $user) {
$cuser = array($user->login->username,$user->name->givenName,$user->name->familyName);
array_push($_SESSION['googleUsers'],$cuser);
}
$_SESSION['googleDomain'] = $domain;
} catch (Exception $e) {
$_SESSION['googleUsersError'] = 1;
}
With debug active everything works, however, when debug is set to 0, nothing more but a blank screen appears. I tried to get the exception message, however it does not appear either. It almost seems like "exit" or "die" is executed. Anyone have had such issue before?
app/tmp/logs/error.log. A white screen most of the time means an error in CakePHP. Another cause may be that CakePHP tries to redirect the user, but that the redirect doesn't work (headers already sent?) - thaJeztah