Richard G
Richard G

Reputation: 5683

Identity for anonymous user in Spring MVC application

I would like to be able to identify unique anonymous users so I may store some information in the database for that user. Something like a guest shopping cart.

I don't particularly want to use session, because I like the easy fail-over between servers if I keep building with a no-session-data approach.

Is there any way in either spring security or generic spring to get an identity token that I can use to identify particular anonymous users (primary key)?

Upvotes: 2

Views: 1847

Answers (2)

Serhii
Serhii

Reputation: 7543

I've solved this issue in for spring security 4. Solution is here just inject into the filter correspond services look up to user's info.

Upvotes: 0

erhun
erhun

Reputation: 3649

Actually i don't know alternative way in Spring Security or Spring in general but why you just get SessionId from session.getId()

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.Returns:a string specifying the identifier assigned to this session

and save this sessionId to db. This way you not fail between server, you already save it to database.

Upvotes: 0

Related Questions