5to10pm |
04-14-2017 10:11 PM |
Logout code not working.
I modified my php.ini to set session domain
PHP Code:
session.cookie_domain='.maindomain.com'
In VB, I changed cookie domain to .maindomain.com. And implemented single sign on on external page using this code. Using latest vBulletin i.e. 5.3.0
I also want to implement auto logout feature. So here is the code that I wrote:
PHP Code:
// Path to your vBulletin installation $vbpath = 'D:/XAMPP/htdocs/forum.maindomain.com/';
// Start login script define('CSRF_PROTECTION', false); require_once($vbpath . '/includes/vb5/autoloader.php'); vB5_Autoloader::register($vbpath); vB5_Frontend_Application::init('config.php');
////logout $api = Api_InterfaceAbstract::instance(); $userid=false; $userInfo = $api->callApi('user', 'fetchProfileInfo', array($userid)); //need logouthash, so calling fetchprofileinfo if(!empty($userInfo)){ //echo $userInfo['logouthash'].'<br>'; $x=$api->callApi('user', 'logout', array($userInfo['logouthash'])); var_dump($x); ///output: array(2) { ["sessionhash"]=> string(32) "7539b3b1778217bd012ef1dce83019b6" ["apiaccesstoken"]=> NULL } }
But the above code is not working. somebody, please provide working external logout script.
Thank you in advance
--------------- Added [DATE]1492219558[/DATE] at [TIME]1492219558[/TIME] ---------------
I don't know why, but deleting the cookies after calling the logout did the trick
PHP Code:
setcookie("bbsessionhash", "", -1, '/', ".maindomain.com"); setcookie("bblastvisit", "", -1, '/', ".maindomain.com"); setcookie("bblastactivity", "", -1, '/', ".maindomain.com"); setcookie("bbpassword", "", -1, '/', ".maindomain.com"); setcookie("bbuserid", "", -1, '/', ".maindomain.com");
|