invalidateSessions()

Ends one or more sessions specified by a sessionId.

Syntax

InvalidateSessionsResult = binding.invalidateSessions(string[] sessionIds);

Usage

Use this call to end one or more sessions.

You can also use logout() to end just one session, the session of the logged-in user.

Sample Code—Java

public void invalidateSessions(String [] sessionIds) {
    try {
        InvalidateSessionsResult[] results;
        results = binding.invalidateSessions(sessionIds);
        for (InvalidateSessionsResult result : results) {
            // check results for errors
            if (!result.isSuccess()) {
                Error[] errors = result.getErrors();
                if (errors.length > 0)  {
                  StatusCode code = errors[0].getStatusCode();
                  String message = errors[0].getMessage();
                  // handle error. We just print the first error out for sample purposes.
                  System.out.println("Error code: " + code);
                  System.out.println("Error message: " + message);
                }
            }
        }
    }
    catch (Exception e) {
        // handle exception. We just print it out for sample purposes.
        System.out.println("Unexpected error encountered while trying to logout:\n\n" + 
           e.getMessage());
    }
}

Sample Code—C#

public void InvalidateSessions(string [] sessionIds) {
    try {
        InvalidateSessionsResult[] results;
        results = binding.InvalidateSessions(sessionIds);
        for (InvalidateSessionsResult result in results) {
            // check results for errors
            if (!result.Success) {
                StatusCode code = result.Errors[0].StatusCode;
                string message = result.Errors[0].Message;
                // handle error
                ...
            }
        }
    }
    catch (Exception e) {
        Console.WriteLine("Unexpected error encountered while trying to logout:\n\n{0}",
             e.Message);
        // handle exception
        ...
    }
}

Arguments

Name Type Description
sessionIds string[] One or more sessionId strings. Limit 200. You can obtain your sessionId from the SessionHeader.

Response

InvalidateSessionsResult[]

Faults

UnexpectedErrorFault

© Copyright 2000-2009 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.