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

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?.

Cleaning the browser cookies resolved the problem!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

88 views 0 5
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