Read Session Id using Javascript

前端 未结 7 1831
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 06:33

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

7条回答
  •  甜味超标
    2020-12-24 07:06

    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)

提交回复
热议问题