Skip to content

Getting session_id from cookie? #1000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
littlehome-eugene opened this issue Feb 14, 2018 · 2 comments
Closed

Getting session_id from cookie? #1000

littlehome-eugene opened this issue Feb 14, 2018 · 2 comments
Assignees
Labels
for: stack-overflow A question that's better suited to stackoverflow.com

Comments

@littlehome-eugene
Copy link

littlehome-eugene commented Feb 14, 2018

I know session_id is stored in cookie and it is used to retrieve user info upon requests.

However when I look at the cookie value in chrome, and databasse (SPRING_SESSION table), there's no matching session_id.

Also, it perflexes me that SPRING_SESSION has primary_id as primary key and there's no index on session_id.

How can I get the session_id as in request.getSession.getId() from reading cookie ?

@vpavic vpavic self-assigned this Feb 15, 2018
@vpavic vpavic added the for: stack-overflow A question that's better suited to stackoverflow.com label Feb 15, 2018
@vpavic
Copy link
Contributor

vpavic commented Feb 15, 2018

Starting with Spring Session 2.0, session cookie is Base64 encoded by default. See #736 and DefaultCookieSerializer source.

Also starting with 2.0, support for Session#changeSessionId has been added in #835. This means that session stores had to adjust to be able to support changing the session id. For a relational database, this means that original session id is used as primary key, while a separate column keeps track of the current session id.

Regarding reading the session id from cookie, you can either disable Base64 encoding of session cookie or do Base64 decode on the client.

@littlehome-eugene
Copy link
Author

Thank you for the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stack-overflow A question that's better suited to stackoverflow.com
Projects
None yet
Development

No branches or pull requests

2 participants