-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] PHP Warning: SessionHandler::read()
: Session ID is too long or contains illegal characters.
#47126
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
Comments
Same as #46993? |
@brokensourcecode I don't know. I think it's best if you open a PR with your idea to gather some feedback. I close here meanwhile as we still have the other issue. |
nicolas-grekas
added a commit
that referenced
this issue
Aug 1, 2022
…e PHP file sessions (BrokenSourceCode) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46993, #47126 | License | MIT Inside the [`SessionHandlerProxy`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php) class, the code defines `$this->saveHandlerName` to `\ini_get('session.save_handler')` when `$handler` is an instance of [`\SessionHandler`](https://www.php.net/manual/en/class.sessionhandler.php). https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php#L24-L25 But inside the [`NativeSessionStorage`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php) class, the code create an instance of [`StrictSessionHandler`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php) that doesn't inherit from [`\SessionHandler`](https://www.php.net/manual/en/class.sessionhandler.php) and is passed to the [`SessionHandlerProxy`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php) constructor. https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L422-L424 Therefore, we could create a `isWrapper()` method inside the [`StrictSessionHandler`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php) class to check if the wrapped handler is an internal PHP session handler ([`\SessionHandler`](https://www.php.net/manual/en/class.sessionhandler.php)), just like [`AbstractProxy::isWrapper()`](https://github.com/symfony/symfony/blob/818d4dda7de778726123bc6bd49488959d4186e7/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php#L50). That's the only solution I have in mind right now. Commits ------- 4775c88 [HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
47BF
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
6.1.3
Description
Hi, the error is similar to #46777, except that now the issue comes from another reason. Or maybe I misunderstood how Symfony sessions work...
Look at this condition:
symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
Line 169 in 818d4dd
When i'm using
NativeSessionStorage
class,$this->saveHandler->getSaveHandlerName()
returnsuser
but should returnfiles
. Therefore, the whole condition is nevertrue
and the following warning persists:How to reproduce
Possible Solution
Below, the code defines
$this->saveHandlerName
to\ini_get('session.save_handler')
when$handler instanceof \SessionHandler
.symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php
Lines 24 to 25 in 818d4dd
But here, the code instantiates
new StrictSessionHandler(new \SessionHandler())
that is not an instance of\SessionHandler
.symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
Lines 422 to 424 in 818d4dd
So, I'm really not sure, but a possible solution could be as below:
Because both
StrictSessionHandler
and\SessionHandler
implements\SessionHandlerInterface
.Additional Context
No response
The text was updated successfully, but these errors were encountered: