Hi, I need to create a cookie in user macro environment, I can use the velocity context parameter $req, but this only work to get a cookie, not for create.
Can I do this?
Oh, you want to manage cookies on client side?
You can store cookie like this:
document.cookie = "theme=" + encodeURIComponent("blue theme") + "; max-age=" + 60*60*24*30 + "; path=/; domain=thesitewizard.com" ;
Also, Atlassian have api for managing cookies - https://developer.atlassian.com/display/AUI/AJS.Cookie - but it stores all values in one key/value map. But you can try it.
If there is strong requirement to store cookie in macro, then you have to add instance of CookieUtils to Velocity params and then call it like
$cookieUtils.createCookie($name, $value, $req)
Honestly, I didn't try to do that in Confluence macro. But I'm absolutely shure, that it work in Jira's Web Action.
Hope it helps :)
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot