The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a cookie with confluence 4.2?

liljoint
Contributor
June 18, 2012

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?

please help.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 18, 2012

Why do you need to create a cookie? There may be a better solution :-)

liljoint
Contributor
June 18, 2012

I need to make a connection with another server using ajax, But it's not safe, I wanna to create a cookie with a encrypted access code to the other server.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2012

It's not possible to modify the Cookie header when using the JavaScript XMLHttpRequest object to do AJAX calls - see http://stackoverflow.com/a/5123282/1471135

0 votes
grundic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 18, 2012

Oh, you want to manage cookies on client side?

Maybe it's better to use javascript instead of macro?

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 :)

0 votes
grundic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 18, 2012

Maybe com.atlassian.jira.web.util.CookieUtils can help you?

liljoint
Contributor
June 18, 2012

how can I use this in the user macro environment??? can you explain how I can do this?? don't reply a question with another question, please ! XD

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events