Getting SessionID via Javascript in HTML portlet

Discussion created by viral.shah.1 on Apr 16, 2014
Latest reply on Apr 17, 2014 by viral.shah.1


I am running the code in Clarity 13.3 and in ONDemand Env.Not sure upto wht extent it supports the javascript.

I am trying on the below code to get the users sessionID via Javascript in HTML Portlet , but getting "undefined" as output.

 <TITLE> SessionID </TITLE>

<script type="text/javascript">

function getCookie(c_name)
var i, cookieName, cookieValue, thisCookie, allCookies = document.cookie.split(";");
for (i = 0; i < allCookies.length; i++)
  cookieName = allCookies[i].split('=')[0];
  cookieValue = allCookies[i].split('=')[1];
if (cookieName == c_name)
return unescape(cookieValue);

var sessionCookie = getCookie('sid');

Please let me know if i am missing anything here or the OnDemand Env does not support this.

Appreciate any help or suggestions on this.