Newer Version Available
invalidateSessions()
Ends one or more sessions specified by a sessionId.
Syntax
1InvalidateSessionsResult = connection.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
This sample invalidates a set of sessions. The method in this sample takes an array of session IDs passed in as String values. The method then calls invalidateSessions() with this array and then checks the results for any errors.
1public void invalidateSessionsSample(String[] sessionIds) {
2 try {
3 InvalidateSessionsResult[] results;
4 results = connection.invalidateSessions(sessionIds);
5 for (InvalidateSessionsResult result : results) {
6 // Check results for errors
7 if (!result.isSuccess()) {
8 if (result.getErrors().length > 0) {
9 System.out.println("Status code: "
10 + result.getErrors()[0].getStatusCode());
11 System.out.println("Error message: "
12 + result.getErrors()[0].getMessage());
13 }
14 } else {
15 System.out.println("Success.");
16 }
17 }
18 } catch (ConnectionException ce) {
19 ce.printStackTrace();
20 }
21}Sample Code—C#
This sample invalidates a set of sessions. The method in this sample takes an array of session IDs passed in as String values. The method then calls invalidateSessions() with this array and then checks the results for any errors.
1public void invalidateSessionsSample(string[] sessionIds)
2{
3 try
4 {
5 InvalidateSessionsResult[] results;
6 results = binding.invalidateSessions(sessionIds);
7 foreach (InvalidateSessionsResult result in results)
8 {
9 // Check results for errors
10 if (!result.success)
11 {
12 if (result.errors.Length > 0)
13 {
14 Console.WriteLine("Status code: " +
15 result.errors[0].statusCode);
16 Console.WriteLine("Error message: " +
17 result.errors[0].message);
18 }
19 }
20 else
21 {
22 Console.WriteLine("Success.");
23 }
24 }
25 }
26 catch (SoapException e)
27 {
28 Console.WriteLine("An unexpected error has occurred: " +
29 e.Message + "\n" + e.StackTrace);
30 }
31}Arguments
| Name | Type | Description |
|---|---|---|
| sessionIds | string[] | One or more sessionId strings. Limit 200. You can obtain your sessionId from the SessionHeader. |