Set custom cookies using Google Apps Script

十年热恋 提交于 2019-12-12 03:39:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!