[SalesForce] how to get sessionID in html area component

How can i get the sessionID in the html area component , in the sidebar , using javascript without referring to the connection.js , Is this possible

Best Answer

Yes. It is stored in a cookie named sid so a

var sid = document.cookie.match('sid=([^;]*)')[1];

Should do the work. Or if you want something simpler to read

var strCookies = document.cookie;
var cookiearray = strCookies.split(';')
for(var i=0; i<cookiearray.length; i++){
  name = cookiearray[i].split('=')[0];
  value = cookiearray[i].split('=')[1];
  if(name == 'sid')
     sid = value;
}