简体   繁体   中英

how do i/can i access a sessionid cookie through javascript?

I've installed the cookie extension for jquery, and am attempting to access the session id cookie.

I currently have two cookies for my session - see screenshot below:

Cookie屏幕快照

however, $.cookie() only lists one:

> $.cookie()
Object {csrftoken: "fFrlipYaeUmWkkzLrQLwepyACzTfDXHE"}
> $.cookie('sessionid')
undefined

can i/how do i access the sessionid cookie from javascript?

The session id cookie should be marked as HTTP Only, preventing access from javascript. This is a security issue, preventing session hijacking via an xss vulnerability.

You can see in your screenshot that the cookie is indeed marked as HTTP.


If you want to learn more about the flag see here . Originally implemented by IE, most browsers support the flag nowadays, and session cookies not marked http-only are considered a security flaw. Also see here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM