1

I'm trying to retrieve JSESSIONID from JavaScript, and I'm getting this kind of problem:

This is my JSESSIONID parameter in cookies:

This is my JSESSIONID parameter in cookies

I'm trying to get it by:

document.cookie.match(new RegExp(name + '=([^;]+)'));

But actually I'm getting undefined, also, trying even by browser console, the document.cookie give me this value:

_ga=GA1.1.1907359526.1634144199; _gid=GA1.1.1178968649.1634144199; _y2=1%3AeyJjIjp7IjE2NjUwOCI6LTE0NzM5ODQwMDAsIjE2NzQyNyI6LTE0NzM5ODQwMDAsIjE2NzQyOCI6LTE0NzM5ODQwMDAsIjE2NzQzNSI6LTE0NzM5ODQwMDAsIjE2ODEyNyI6LTE0NzM5ODQwMDAsIjE2ODc2NCI6LTE0NzM5ODQwMDAsIjE2ODgyNyI6LTE0NzM5ODQwMDAsIjE2ODgzMCI6LTE0NzM5ODQwMDAsIjE2OTIwNiI6LTE0NzM5ODQwMDAsIjE3MDY0MSI6LTE0NzM5ODQwMDAsIjE3MTI4MiI6LTE0NzM5ODQwMDB9fQ%3D%3D%3ALTE5NjU3ODQwMA%3D%3D%3A1; _yi=1%3AeyJsaSI6bnVsbCwic2UiOnsiYyI6MiwiZWMiOjYwLCJsYSI6MTYzNDE0NjkwNjA1MCwicCI6Nywic2MiOjI0Mjl9LCJ1Ijp7ImlkIjoiZGI3NzUwNjUtNjU5MC00ZDU1LWE4ZGEtNGZlODNhZDQyYTY0IiwiZmwiOiIwIn19%3ALTE0MzE4NDYxMTI%3D%3A1

Any suggestions?

P.S. I'm of course in https.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
DarioS
  • 11
  • 1
  • 2
    See the "HttpOnly" column? See how it's checked for the `JSESSIONID` cookie? HttpOnly means it can only be read in the HTTP header, not via JavaScript. – Heretic Monkey Oct 13 '21 at 17:48
  • From [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies): "A cookie with the HttpOnly attribute is inaccessible to the JavaScript Document.cookie API; it's only sent to the server. For example, cookies that persist in server-side sessions don't need to be available to JavaScript and should have the HttpOnly attribute. This precaution helps mitigate cross-site scripting (XSS) attacks." – Álvaro González Oct 13 '21 at 17:50
  • I think this is the problem,i will try changing the server-side configuration, and I'll let you know, thank you – DarioS Oct 13 '21 at 18:11

0 Answers0