brock
brock

Reputation: 449

Is it possible to write a cookie from a google apps script from a google site?

The following simple javascript code in a GAS gadget does not appear to work:

document.cookie="username=John Smith; expires=Mon, 31 Aug 2015 12:00:00 UTC; path=/";

Is this one of those sandbox things that I'm not allowed to do? If so, is there an alternative or workaround?

Upvotes: 1

Views: 2205

Answers (1)

brock
brock

Reputation: 449

The answer is yes, you can. Simply set the domain property of your cookie to ".googleusercontent.com".

However, for me, the cookie is always deleted when I refresh the page, regardless of the expires string. I don't know why this is happening, but I no longer care. I have found a different solution to the underlying problem of saving an email address client side: HTML5 local storage.

Upvotes: 1

Related Questions