-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
destroy session first on regenerate session when session is active #7
destroy session first on regenerate session when session is active #7
Conversation
@samsonasik I've made some improvements to your test and all seems to be working fine - on travis and on local. Please have a look. Tests in that file run in separate process so there is no need for clear the session at the end of the test. |
@michalbundyra thank you, that's ok 👍 |
@michalbundyra any chance for merging ? thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerned with the change of initial intended behavior to exact opposite.
Why was it done in a way explicitly preserving old session with data? session_regenerate_id(true)
could have been used otherwise to achieve what this PR wants to introduce.
Could it possibly be that race condition actually is an issue that cause new session id to be overwritten by one of the parallel requests? As mentioned in docs, say, strict mode regenerating id on empty/missing old session and sending cookie superseding actual session?
@Xerkus I've removed |
This is not a bugfix, but rather improvement that changes behavior. Should target next minor. |
So far these are the only effect of this change that I can think of:
|
We chose not to use As such, the approach here by @samsonasik is the correct one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
@michalbundyra merge-able ? |
@samsonasik Yes, I'll merge it soon, it's on my list, but first I am working on laminas-form. |
fc37047
to
198f5eb
Compare
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
198f5eb
to
8ec093e
Compare
Thanks, @samsonasik! |
Description
re-create PR for #1 . There is a use case when session already started before, and already set some value, eg: on csrf session data on a login form. When authenticate, it call the session regenerate, which session id changed, but left the old session not persisted (unset not applied as session id changed), so old session with the value remain in the disk.
To avoid it, I think we can apply session_destroy() before session_write_close() whenever session is active.