Friday, February 1, 2019

PHP Toolkit New Version (2012.2 and Later) > Sample Code: Logout

Assuming you are using session ID to authenticate requests instead of passing Request Level Credentials, you can terminate a currently active session by invoking logout action. Below is a sample code for performing logout using 2012.2 PHP Toolkit:

function logout2(){
 $service = new NetSuiteService();
 $logoutRequest = new LogoutRequest();
 try{
 $logoutResponse = $service->logout($logoutRequest);
 if (!$loginResponse->sessionResponse->status->isSuccess){
  echo "Logout Error";
 }else {
  echo "Successfully Logged Out";
    }}catch(Exception $e){
  echo $e;
 }
}

No comments:

Post a Comment