How is http session managed from plug-ins?

Hi,

Http requests from a servlet in a plug-in can invoke the request.getSession() and get a wrapper for the session:

com.atlassian.plugin.servlet.PluginHttpSessionWrapper

What is the session object wrapped? Is it related in any way to the user http session in JIRA? Or are plug-ins stateless and are such wraped sessions dummy instances?

Thanks,

Pablo.

2 answers

This widget could not be displayed.

Hi you can use httpSession in your plugin.

your running with Request object then you can store in the session.

String test=(String)request.getSession().getAttribute("userName");

this way you can try in your servlet make sure you set some value to session.

regards,

tousif shaikh.

Just that brings up this related question:

https://answers.atlassian.com/questions/173652/does-setting-session-attributes-from-a-plugin-work-or-is-it-a-bug

setting attributes just in the way you mentioned is not working.

I've also seen that request.getSession().getId() returns different values across servlet calls, like whether a new session instance is created and wrapped per servlet GET/POST call. :(

On the other hand, I know working with session attributes is a quite common feature used by many plug-ins and it should work, but honestly I debugged the classes provided by the atlassian-plugins-servlet-2.10.1.jar (which is bundled with JIRA 5.1) and they looks like wrapping all the servlet related objects like request, response , session... and my bet is that the session wrapper does not keep a singleton instance to manage the plug-in session, in other words: attributes are lost because they are copied to the "A" session instance and read from the "B" instance and the plug-in framework does not copy the attributes from A to B instance.

Maybe this might be related:

https://confluence.atlassian.com/display/JIRAKB/User+is+Constantly+Logged+out+of+JIRA

It's not exactly the same case (JIRA session is not closed), but the issue mentioned in this thread happens every time that the plug-in performs a log (Http basinc authentication) in a 3rd party application. Might that cause session lost in plug-in?.

This widget could not be displayed.

Cleaning the browser cookies resolved the problem!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

526 views 3 19
Read article

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