cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HttpSession: Is there a way to get the browser session id?

Former Member
0 Likes
1,685

Hi all,

I need to allow for multiple sessions in our app. Mostly is OK, except for the popup windows. I think I need to put a "session id" in the page title. I can make a hash of the login time and date and user name, but would really prefer a real session id.

Is there a way I can get the http session id?

Thanks,

--Amy Smith

--Haworth

Accepted Solutions (1)

Accepted Solutions (1)

jamie_cawley
Product and Topic Expert
Product and Topic Expert
0 Likes

Answers (1)

Answers (1)

Former Member
0 Likes

Hi Amy,

Were you able to get this to work by passing in the session id (or another unique value per user session) to the page title and allowing multiple popups of the same page for different sessions?

If so, can you show me the code you used for dynamically setting the title as I was having some issues setting the title based on the session?

Thanks,

Kerby

Former Member
0 Likes

Hi Kerby --

I misspoke (miswrote?) about the page title. I really meant the window title in the window.open() javascript.

window.open('/XMII/CM/APEX/dispatchReport.irpt?isReport=true', 'dispatchReport' + $('#sessionId').val());

This -$('#sessionId').val()- is jquery for the value of the element with and id of sessionId --- like this in the .irpt

<input type="hidden" id="sessionId" value=""/>

Does this help? I can post the javascript to save the session id to the session variable, but it is really hard to post javascript so I don't want to unless you need it too! If you want that let me know.

--Amy Smith

--Haworth

Former Member
0 Likes

Hi Amy,

Could you post it if that'd be ok? Below is what I was trying to do and I think I have a misunderstanding/syntactical issue with what I was trying to do (username+timestamp) but using the sessionID would probably be easier and better.

I tried just adding the userID below and that didn't work, and then I tried using your syntax for referencing the txtLoginName+timestamp and didn't seem to work either. Thoughts? I normally work in the BLS so less familiar with the IRPT popup passing.

Thanks,

Kerby

var strUserID=document.jaGrid_Procedures.getPropertyValue("IllumLoginName")"_"this.getTimeStamp();

// Open window, passing in parameters.

window.open("ProductSelector.irpt?&objSelected=" + strObjSelected

+ "&intWidth=" + intWidth,

"Product" + <strUserID/UniqueId here>

"height=650,width=" + (intWidth+40) + ",status=yes,toolbar=no,menubar=no,location=no,resizable=1");

Syntax of loginname:

<input type=HIDDEN READONLY value="" name=txtLoginName>

Former Member
0 Likes

Hi Kerby,

Actually using the sessionId is *much* harder than what you were trying. It requires a jsp to retrieve the

session id when the user logs on, javascript to store it in a session variable and an element on the page

to retrieve the value of the session variable. Not simple and I am using ajax to store the variable.

If the user name and timestamp would work for you I suggest you pursue that. Especially if you are

not comfortable with web pages and javascript.

BTW: -this.getTimeStamp()- I don't recognize that as valid javascript. Maybe it is, but it didn't work for me.

I suggest the following which will yield something like this ---> Productmyuserid_1266607995753

So, every window opened should be unique because of the milliseconds value in the timestamp.


var dt = new Date();
var strUserID=document.jaGrid_Procedures.getPropertyValue("IllumLoginName")+"_"+dt.getTime();
window.open("ProductSelector.irpt?&objSelected=" + strObjSelected + "&intWidth=" + intWidth,
"Product" + strUserID,
"height=650,width=" + (intWidth+40) + ",status=yes,toolbar=no,menubar=no,location=no,resizable=1");

--Amy Smith

--Haworth

Former Member
0 Likes

Hi Amy,

Thanks so much for the help. It works for me now! What you showed is actually what I had tried in the beginning but the getTimeStamp() was causing issues with it. The reason why (after comparing why your dt.getTime worked) is that the getTimeStamp returns a '-' after the day and the - caused an issue within the url. e.g. 2010219-121905804. When I replaced the - with an _ then it worked fine.

Thanks alot for the help.

Kerby