Clarity

  • 1.  Getting SessionID via Javascript in HTML portlet

    Posted Apr 16, 2014 03:38 PM

    Hi,

    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.

     <HTML>
     <HEAD>
     <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');
    window.alert(sessionCookie);
    </script>
    </HEAD>
    </HTML>

    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.



  • 2.  RE: Getting SessionID via Javascript in HTML portlet

    Posted Apr 16, 2014 04:56 PM

     

    The cookie you are looking for is sessionId.

    I normally get it like this:

    function getSessionCookie() {
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++)
              {
              var c = ca[i].trim();
              if (c.indexOf("sessionId=")==0) return c.substring(name.length,c.length);
              }
        return "";
    }
    var sessionCookie = getSessionCookie();

     

    V/r,

    Gene



  • 3.  RE: Getting SessionID via Javascript in HTML portlet

    Posted Apr 17, 2014 09:23 AM

    Hi, 

    Tried the code as suggested, but throwing error like Object doesn't support this property or method.

    Same Error when i tried running saving as .html file.

    Is it beacuse CA Clarity OnDemand Env not supporting javascript in Html portlet?