Frage

I am running my web application on Weblogic application server.I am making several ajax calls in my application via Jquery UI $ajax and other Jquery Plugins (i.e. Jquery Datatables and JSTree)

Now i need to maintain same session in all these calls.Any user in the same session should only be allowed to do this.For this i am trying to append the JSESSIONID to every ajax call.

The problem with this approach is that i don't know how to get this value in my javascript file.If i write my code in JSP ,i can do that but in javascript i do not know of a way to do this.

Please help me with a way to set it into Jquery so that it gets passed with every request.

Thanks

War es hilfreich?

Lösung

The best solution is to put it in a session cookie, which will be passed with the AJAX requests and can be interpreted by the server. No changes needed to any JavaScript AJAX requests.

The next would be more complicated. You could write a jQuery.ajaxSend() function that checks the request url (to make sure it's one you need to add the session ID to) and add the sessionID to the data object before the AJAX request is made.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top