How to get the jSessionId from a velocity template in liferay

Just a quick tip because I´ve been searching for it a while.

When you´re creating inter - portal links and your portal is using jsessionids to identify the logged in user you might run into the situation where a link created in a web content (JournalArticle Link To Page) doesn´t contain the jsessionid and everyone who follows that link is no longer logged in.

What you need to do in this situation is to attach the jsession id to your link. This is how you do it. You can use the "Link To Page" Structure Entity that liferay is giving you and then simply add the portlet session id:

<a href="${link.getUrl()};jsessionid=$request.get('portlet-session-id')">