问题
is it possible to set a custom cookie through a Google Apps script gadget embedded in a Google site. I've been trying using the HtmlService class (through document.coookie in a script from the html file) but it doesn't seem to generate the cookie. I'm assuming this must be by design (i.e. Caja sanitisation). Is there another way?
Thanks
回答1:
It is not possible, by design, but you shouldn't need to; you can store information about the current user in UserProperties.
回答2:
It's acctually possible if you use the iframe option just like this:
function doGet(e) {
return HtmlService.createHtmlOutputFromFile("index.html")
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
// after that you may use (On "index.html"):
// document.cookie = "cookieName=1234";
best regards.
来源:https://stackoverflow.com/questions/12416286/set-custom-cookies-using-google-apps-script