-
Notifications
You must be signed in to change notification settings - Fork 9
inhibit creation of new session files for cookie-less requests #36
Conversation
Hello @weierophinney, @batumibiz I provided a fix (co the code for testing from here) for #33 This stills works differently from php DETAILS
TODO
|
starting session will not cause any error
Dear @pine3ree Call SessionPersistence implies that we in any case You must start the session. If we do not, there might be compatibility issues with other scripts, which I probably will use in my application (scripts expect that the session has). If no COOKIE for this session, they need to create. In the original package the problem is in this line return new Session($_SESSION, $sessionId); And it is necessary that was so: return new Session($_SESSION, $id); and the problem will be simply solved :) |
I corrected that issue here |
Dear @batumibiz , yes that was my first solution (see one of the first comments in #33 (comment)). Having But then I found out that we could just avoid creating a new session file when there is no access to any session data and no session file (id) targeted by the request (no request cookie). If a request cookie is present, a new session will be started anyway (thus opening an old session file or creating a new one) because we need to retrieve persisted session data (if any) and use it to initialize the Session instance. kind regards |
I think so right |
Hello @batumibiz, there is also another thing to consider in https://github.com/zendframework/zend-expressive-session-ext/blob/master/src/PhpSessionPersistence.php#L106: the test |
Yes I agree. |
test/PhpSessionPersistenceTest.php
Outdated
|
||
$files = glob("{$sessionSavePath}/sess_*"); | ||
|
||
$this->assertSame(1, count($files)); |
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.
should can use $this->assertCount()
:
$this->assertSame(1, count($files)); | |
$this->assertCount(1, $files); |
test/PhpSessionPersistenceTest.php
Outdated
|
||
$files = glob("{$sessionSavePath}/sess_*"); | ||
|
||
$this->assertSame(0, count($files)); |
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.
should can use $this->assertCount()
:
$this->assertSame(0, count($files)); | |
$this->assertCount(0, $files); |
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.
Thanks @samsonasik! Will add after #38 is pulled. Otherwise phpunit failures could randomly happen. regards!
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.
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.
@samsonasik using assertCount here. kind regards.
Hello again everyone! Compatibility with ordinary PHP sessions is not needed and they are used only as a data storage mechanism. I don't think anyone using Expressive will use simple native sessions from PHP at the same time. Therefore, it is logical to do as @pine3ree suggested, that is, for new sessions that do not have COOKIES and no data, do not run session_start () at all. If no one has any objections, then please cancel my PR |
…into develop Forward port #36 Conflicts: CHANGELOG.md
Thanks, @pine3ree! Cherry-picked to master, as I consider this a bugfix, and releasing immediately as version 1.5.1. |
No description provided.