Remove Session Property

This section provides developers with information on how to remove properties of a session. Documentation for the REST protocol, as well as code samples for Java, PHP, and cURL, are provided below.

REST

The REST noun for removing properties on a session is as follows:

  • Relative Noun: AuthenticatedSession/$sessionID/Properties[/$propertyName]. This is the relative path of the URL that should appear after the OTIS server application name. The $sessionID variable identifies the authenticated session whose properties are to be removed. The $propertyName variable identifies the property to be removed. It is optional. If omitted, ALL session properties will be removed. For example:

Remove the "Property1" property:

https://wag.bandit-project.org/otis/AuthenticatedSession/AB6745EDF9A32BCEAB6745EDF9A32BCE/Properties/Property1

Remove ALL session properties:

https://wag.bandit-project.org/otis/AuthenticatedSession/AB6745EDF9A32BCEAB6745EDF9A32BCE/Properties
  • HTTP Method: DELETE.
  • Request/Response message details: None
  • Description: Removes properties for the authenticated session (specified by the $sessionID variable).

Java

The following is example Java code that demonstrates how to remove properties of a session:

try
{

   // The session variable is an IAuthSession object. -- Remove property "SimpleString" by setting its value to null.
			
   session.setProperty( "SimpleString", null);

   // Remove All session properties

   session.removeAllProperties();
}
catch (AuthSessionException exception)
{
    System.out.println("AuthSessionException: " + exception);
}

The OTIS client Java library may be downloaded from the OTIS download page.

PHP

The following is PHP example code of how to remove a single session property named "Property1". It is assumed that the $sessionURI variable contains the URI for the authenticated session:

$Host = "wag.bandit-project.org";

// Generate the request header using an xml 
$ReqHeader =
"DELETE /otis/AuthenticatedSession/" . $sessionURI . "/Properties/Property1 HTTP/1.1\n".
"Host: $Host\n".
(($sessionSecret) ? ("SessionSecret: " . $sessionSecret . "\n") : "") .
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: 0\n".
"Connection: Close\n\n";

// Open the connection to the host
$socket = fsockopen("wag.bandit-project.org", 80);

// Do the GET; store in "Result".
fputs($socket, $ReqHeader);
while (!feof($socket)) 
{
   $tmp = fgets($socket, 128);
   //if the line contains an xml tag, add it
   if(strpos($tmp, ">"))
   {
      $Result .= $tmp;
   }
}

The following is PHP example code of how to remove ALL session properties. It is assumed that the $sessionURI variable contains the URI for the authenticated session:

$Host = "wag.bandit-project.org";

// Generate the request header using an xml 
$ReqHeader =
"DELETE /otis/AuthenticatedSession/" . $sessionURI . "/Properties HTTP/1.1\n".
"Host: $Host\n".
(($sessionSecret) ? ("SessionSecret: " . $sessionSecret . "\n") : "") .
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: 0\n".
"Connection: Close\n\n";

// Open the connection to the host
$socket = fsockopen("wag.bandit-project.org", 80);

// Do the GET; store in "Result".
fputs($socket, $ReqHeader);
while (!feof($socket)) 
{
   $tmp = fgets($socket, 128);
   //if the line contains an xml tag, add it
   if(strpos($tmp, ">"))
   {
      $Result .= $tmp;
   }
}

cURL

The following is example cURL code that demonstrates how to remove ALL session properties:

if [ -e secret.hdr ] ; then secret=`cat secret.hdr` ; else secret="nosecret: none" ; fi
curl -b cookies.txt -X DELETE https://wag.bandit-project.org/otis/Properties

This assumes you have already set up an authenticated session and are using a cookies.txt file to store/retrieve the otisSessionID cookie and that the session secret has been stored in a file called secret.hdr (See AuthenticateUser for details).

The following is example cURL code that demonstrates how to remove a single session property called "SimpleStringProperty":

if [ -e secret.hdr ] ; then secret=`cat secret.hdr` ; else secret="nosecret: none" ; fi
curl -b cookies.txt -H "${secret}" -X DELETE https://wag.bandit-project.org/otis/Properties/SimpleStringProperty

This assumes you have already set up an authenticated session and are using a cookies.txt file to store/retrieve the otisSessionID cookie and that the session secret has been stored in a file called secret.hdr (See AuthenticateUser for details).