-
Notifications
You must be signed in to change notification settings - Fork 823
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 on logout instead of restarting it #10023
Conversation
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.
Looking at Session, it looks like restart
will call destroy
.
silverstripe-framework/src/Control/Session.php
Lines 246 to 250 in ae61be3
public function restart(HTTPRequest $request) | |
{ | |
$this->destroy(); | |
$this->start($request); | |
} |
And Session::init()
looks like it wants to start a new session if one doesn't already exists.
silverstripe-framework/src/Control/Session.php
Lines 226 to 239 in ae61be3
public function init(HTTPRequest $request) | |
{ | |
if (!$this->isStarted() && $this->requestContainsSessionId($request)) { | |
$this->start($request); | |
} | |
// Funny business detected! | |
if (self::config()->get('strict_user_agent_check') && isset($this->data['HTTP_USER_AGENT'])) { | |
if ($this->data['HTTP_USER_AGENT'] !== $this->userAgent($request)) { | |
$this->clearAll(); | |
$this->restart($request); | |
} | |
} | |
} |
I suspect that in 99% of logouts, you'll be redirected to some page that will want to start a new session.
Thanks for your reply.
Yes,
Correct, but we don't re-init the session after logout.
That might be the case, but that really is up to the developer building the site. If the target page needs a session, it can/will create it. But we don't need to force it. right? |
Whilst I agree with @maxime-rainville that most pages will probably start a session anyway, there's no point forcing the session to be started unless it's really needed. So I think this change is sensible. I think it should go into 4 branch, though. Not 4.8. |
e3ee6fb
to
7dc5cee
Compare
7dc5cee
to
3e2ca30
Compare
@dhensby I have rebased this. Thanks. |
Apparently there are some linting issues 😕 |
IMHO there is no reason to keep the session around after logout? When you visit a public page the session is not started either, so there is no reason to keep a session around after logout.