[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1558
  • Last Modified:

HELP: extracting JSESSIONID from document.cookie

What is the industry standard/professional way to extract JSESSIONID=SESSION from document.cookie?
so that finally SESSION is var "session_id"?

Pretty much so that most possible browsers are supported and fail safe...

Thank you very much...
  • 2
1 Solution
in client side u can read cookies
u probably need the readcookie() function from here


InGearXAuthor Commented:
Thank you archrajan;

I have found it at: http://www.quirksmode.org/js/cookies.html
function readCookie(name)
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for(var i=0;i < ca.length;i++)
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      return null;

So I guess I call it as: readCookie("JSESSIONID") ?

PS forgot to post in original file:
(Actual code that examples a practical working solution is obviously the best solution...)
I have cooked up a 'home' solution, but and will post it regardlessly later to admire or laugh at, but am looking for professional answer/solution...
>>>but am looking for professional answer/solution...

There is no other professional answer/solution
You have to read the cookies with a javascript function.. and that is how its done...

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now