// read the user login token from a cookie
Shiny.addCustomMessageHandler("readCookie", function(message) {
    var cookie = readCookie();
    Shiny.onInputChange("cookie",cookie);
});

function readCookie() {
	name = "org.sagebionetworks.security.user.login.token";
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

// read the user login token from a cookie
Shiny.addCustomMessageHandler("readCookie", function(message) {
    var cookie = readCookie();
    Shiny.onInputChange("cookie",cookie);
});

function readCookie() {
  const Http = new XMLHttpRequest();
  const url='https://staging.synapse.org/Portal/sessioncookie';
  Http.open("GET", url);
  Http.send();
  Http.onreadystatechange=(e)=>{return(Http.responseText)};
}

use new endpoint to get session cookie