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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

112 views 0 3
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