I have implemented Siteminder SSO Login. Everything works fine, but I am not able to remove the cookies SMSESSION, and PHPSESSID. I have read the other questions and tried the code, but all to no avail. The code I am using currently is:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script language="JavaScript">
function delCookie() {
alert("inside delete cookie");
var expireNow = new Date();
document.cookie = "SMSESSION=; expires=Thu, 01-Jan-70 00:00:01 GMT; domain=.<domain>.<com>; path=/";
document.cookie = "SMTRYNO=0; domain=.<domain>.<com>; path=/";
document.cookie = "JSESSIONID=; domain=.<domain>.<com>; path=/";
document.cookie = "sapj2ee_*=; domain=.<domain>.<com>; path=/";
document.cookie = "MYSAPSSO2=; path=/";
document.cookie = "SMSESSION=NO; domain=.<domain>.<com>; path=/";
// alert(document.cookie);
location.href = "http://www.<domain>.<com>";
}
</script>
Any help would be appreciated! PHP code for removing cookies added below:
//remove session vars
session_unset();
// sends as Set-Cookie to invalidate the session cookie
if (isset($_COOKIE[session_name()])) {
$params = session_get_cookie_params();
setcookie(session_name(), '', 1, $params['path'], $params['domain'], $params['secure'], isset($params['httponly']));
}
//try for SMSESSION
//$params = session_get_cookie_params();
//setcookie(session_name(), '', 0, $params['path'], $params['domain'], $params['secure'], isset($params['httponly']));
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie)
{
$mainCookies = explode('=', $cookie);
$name = trim($mainCookies[0]);
setcookie($name, '', 1);
setcookie($name, '', 1, '/');
}
// Finally, destroy the session.
session_destroy();
This removes all cookies and session vars, apart from SMSESSION.
First, deleting those cookies is a very bad idea/practice.
1) For the PHPSESSIONID cookie, you just have to destroy your session. Documentation here
2) SMSESSION is handled by the SiteMinder web agent installed on your application server. You must not mess with it. If you want to destroy the SiteMinder session, just redirect the user to the logout url of your siteminder setup.