You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be useful to add a reference to the ServiceRequest to the SessionStore methods. I'm currently writing a web application with an SQL based session storage backend. My situation is this:
I'd like to write certain information about the request (e.g. the remote IP address and the user agent) into the database.
I need the ID (primary key) of the session entity (which is an u64) in the rest of the application.
I want to only create and update the session if necessary.
This is currently not possible without also being very hacky: because of requirement 3, I only create a session once the user logs in, therefore I cannot just write the information I need into the session everytime because it will trigger a save or update everytime. What I currently do is: in load, I write the session id and token into the returned HashMap, and in save and update, I remove those keys before writing to the database. My authentication middleware then extracts the id from the session and updates the session in the database, which means there are two updates to the same row (in two different transactions). There are also some further writes into the database related to the session, which could theoretically all be put into one transaction without these workarounds. All of this complexity could be eliminated if I had the ServiceRequest in the SessionStore methods.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I think it would be useful to add a reference to the
ServiceRequest
to theSessionStore
methods. I'm currently writing a web application with an SQL based session storage backend. My situation is this:This is currently not possible without also being very hacky: because of requirement 3, I only create a session once the user logs in, therefore I cannot just write the information I need into the session everytime because it will trigger a
save
orupdate
everytime. What I currently do is: inload
, I write the session id and token into the returnedHashMap
, and insave
andupdate
, I remove those keys before writing to the database. My authentication middleware then extracts the id from the session and updates the session in the database, which means there are two updates to the same row (in two different transactions). There are also some further writes into the database related to the session, which could theoretically all be put into one transaction without these workarounds. All of this complexity could be eliminated if I had theServiceRequest
in theSessionStore
methods.Beta Was this translation helpful? Give feedback.
All reactions