public static function logout($campaignID) {
    $campaignIDs = [];
    $membershipIDs = [];
    $fullNames = [];
    $memberIDs = [];

    $request = \Drupal::request();
    $session = $request->getSession();

    if (!empty($session->get('openy_campaign'))) {
      $openyCampaignSession = $session->get('openy_campaign');
      $campaignIDs = $openyCampaignSession['campaign_ids'];
      $membershipIDs = $openyCampaignSession['membership_ids'];
      $fullNames = $openyCampaignSession['full_names'];
      $memberIDs = $openyCampaignSession['member_ids'];
    }

    // Delete Campaign ID, Membership ID, internal Member ID and Full name from SESSION.
    if (in_array($campaignID, $campaignIDs)) {
      $newCampaignIDs = array_diff($campaignIDs, [$campaignID]);

      $membershipID = $membershipIDs[$campaignID];
      $newMembershipIDs = array_diff($membershipIDs, [$membershipID]);

      $fullName = $fullNames[$campaignID];
      $newFullNames = array_diff($fullNames, [$fullName]);

      $memberID = $fullNames[$campaignID];
      $newMemberIDs = array_diff($memberIDs, [$memberID]);

      Cache::invalidateTags(['member:' . $memberID]);

      $session->set('openy_campaign', [
        'campaign_ids' => $newCampaignIDs,
        'membership_ids' => $newMembershipIDs,
        'full_names' => $newFullNames,
        'member_ids' => $newMemberIDs,
      ]);
    }
  }
public static function logout($campaignID) {
    $campaignIDs = [];
    $membershipIDs = [];
    $fullNames = [];
    $memberIDs = [];

    $request = \Drupal::request();
    $session = $request->getSession();

    if (!empty($session->get('openy_campaign'))) {
      $openyCampaignSession = $session->get('openy_campaign');
      $campaignIDs = $openyCampaignSession['campaign_ids'];
      $membershipIDs = $openyCampaignSession['membership_ids'];
      $fullNames = $openyCampaignSession['full_names'];
      $memberIDs = $openyCampaignSession['member_ids'];
    }

    // Delete Campaign ID, Membership ID, internal Member ID and Full name from SESSION.
    if (in_array($campaignID, $campaignIDs)) {
      $newCampaignIDs = array_diff($campaignIDs, [$campaignID]);

      $membershipID = $membershipIDs[$campaignID];
      $newMembershipIDs = array_diff($membershipIDs, [$membershipID]);

      $fullName = $fullNames[$campaignID];
      $newFullNames = array_diff($fullNames, [$fullName]);

      $memberID = $fullNames[$campaignID];
      $newMemberIDs = array_diff($memberIDs, [$memberID]);

      Cache::invalidateTags(['member:' . $memberID]);

      $session->set('openy_campaign', [
        'campaign_ids' => $newCampaignIDs,
        'membership_ids' => $newMembershipIDs,
        'full_names' => $newFullNames,
        'member_ids' => $newMemberIDs,
      ]);
    }
  }
public static function logout ( $ campaignID ) { $ campaignIDs = [ ] ; $ membershipIDs = [ ] ; $ fullNames = [ ] ; $ memberIDs = [ ] ; $ request = \ Drupal :: request ( ) ; $ session = $ request -> getSession ( ) ; if ( ! empty ( $ session -> get ( 'openy_campaign' ) ) ) { $ openyCampaignSession = $ session -> get ( 'openy_campaign' ) ; $ campaignIDs = $ openyCampaignSession [ 'campaign_ids' ] ; $ membershipIDs = $ openyCampaignSession [ 'membership_ids' ] ; $ fullNames = $ openyCampaignSession [ 'full_names' ] ; $ memberIDs = $ openyCampaignSession [ 'member_ids' ] ; } // Delete Campaign ID, Membership ID, internal Member ID and Full name from SESSION. if ( in_array ( $ campaignID , $ campaignIDs ) ) { $ newCampaignIDs = array_diff ( $ campaignIDs , [ $ campaignID ] ) ; $ membershipID = $ membershipIDs [ $ campaignID ] ; $ newMembershipIDs = array_diff ( $ membershipIDs , [ $ membershipID ] ) ; $ fullName = $ fullNames [ $ campaignID ] ; $ newFullNames = array_diff ( $ fullNames , [ $ fullName ] ) ; $ memberID = $ fullNames [ $ campaignID ] ; $ newMemberIDs = array_diff ( $ memberIDs , [ $ memberID ] ) ; Cache :: invalidateTags ( [ 'member:' . $ memberID ] ) ; $ session -> set ( 'openy_campaign' , [ 'campaign_ids' => $ newCampaignIDs , 'membership_ids' => $ newMembershipIDs , 'full_names' => $ newFullNames , 'member_ids' => $ newMemberIDs , ] ) ; } }
Logout member by Campaign ID. Delete it from SESSION.

@param $campaignID
int Campaign node ID.
Logout member by Campaign ID . Delete it from SESSION .