views:

3723

answers:

3

Is it by any means possible to read the browser session id using javascript?

+6  A: 

Yes. As the session ID is either transported over the URL (document.location.href) or via a cookie (document.cookie), you could check both for the presence of a session ID.

Gumbo
sarnath'd damn you :) Also worth mentioning some platforms write this out to a hidden field in a retrievable, determinable way.
annakata
+4  A: 

As far as I know, a browser session doesn't have an id.

If you mean the server session, that is usually stored in a cookie. The cookie that ASP.NET stores, for example, is named "ASP.NET_SessionId".

Guffa
A: 

hi. you can receive the session id by issuing the following regular expression on document.cookie:

alert(document.cookie.match(/PHPSESSID=[^;]+/));

in my example the cookie name to store session id is PHPSESSID (php server), just replace the PHPSESSID with the cookie name that holds the session id. (configurable by the web server)

ufk