Setting a cookie using Atlassian Javascript


I'm trying to set a cookie using Atlassian Javascript (AJS) by an Ajax call like the following:"DREAMBROKER_COOKIE", " ");
alert("success in setting cookie"+"DREAMBROKER_COOKIE"));

This way setting the cookie isn't working. If I set the cookie value directly using browser, it works. So, my cookie setting is not perfect. Can anyone help me set the cookie using AJS or provide any Atlassian workaround on this?



1 answer

For me it does work if I put it on DocReady. For example:

AJS.$(document).ready(function() {"test","banana");
	var mycookie ="test");

Hi according to you the format I posted above should work, right? Unfortunately it's not working. When I hit the above mentioned url:

through browser, I get my cookie and can work which are dependent on that. Could you tell me how I can achieve that?


Oh wait, you're not trying to cookie save the url, but the result when calling this url?

Right, I want to save the result when calling the url. Is it possible to save the result as cookies?

Also, if that's not possible, I want to save cookies like the following one using accessname and another using password (better way I think):

AJS.$.cookie("accessname", encodeURIComponent(<userName>), {expires: 1, path: '/', domain: '', secure: true} );

In this format if I remove domain ( and secure params, it works well but with these it doesn't work. Notice that I used JQuery cookie not the atlassian one because in atlassian format like below:"test","banana");

I can give the cookie name and value only but I need to provide other params like path, expire, domain etc. Is there a way to provide all these params in"test","banana") this format?


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,942 views 12 18
Join discussion

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot