Need help with springboot HttpSession data retrieval

Ive been trying for the entire day to figure out as to why ive not been able to retrieve data ive stored in HttpSession mena to be retrieved later when sending a request through another route, in my example, when I logged in and authenticated, I would set a username inside an HttpSession instance in hopes to store it and retrieve it later. When the login was successful and got redirected to the dashboard where it was supposed to say "welcome, <insert user name here>" i ofc work with angular, so I have to send a GET request to retrieve the user from the session, but, the issue lies here : when I logged in, I did save the username inside the spring boot session, but when I sent a GET request after I had logged in, the data was suddenly gone from the session? when I executed session.getAttribute("user") it returned null, when I debugged it mid login and put a SOP there, it showed me that there is now a "user" key inside session, but at any other page, when I call back to spring boot to check the session, suddenly the session's empty.
6 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @clueless! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
clueless
cluelessOP2mo ago
only clue that id gotten ever since was that JSESSIONID changes with each request sent to retrieve it for some reason, i thought this means that the session data is gonna get lost when calling from another route after i had logged in. https://media.discordapp.net/attachments/1393329011429605466/1393329018463588503/spring.png?ex=68736f04&is=68721d84&hm=140506660118663cbe62a459b25856adc5f367ec386756b12bc0241d9a99996a&=&format=webp&quality=lossless&width=1578&height=519
clueless
cluelessOP2mo ago
(the multiple "+"es arent part of the JSESSIONID ofc, just means to debug my code) pls help me with this ive been stuck since days:boohoo:
straightface
straightface2mo ago
when making the GET request are you sending right auth token?
clueless
cluelessOP2mo ago
the tokens that are sending properly into the website's cookies are the XSRF and the JSESSIONID only difference is JSESSIONID is constantly changing and unstable with each request
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?