-
Notifications
You must be signed in to change notification settings - Fork 7.9k
User Session Serializer #2205
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
User Session Serializer #2205
Conversation
…n-user-serializer
…n-user-serializer
…n-user-serializer
Comment on behalf of krakjoe at php.net: labelling |
When this is ready for discussion, please squash the commits and use a sensible log message ... the log is very noisy ... |
@@ -86,5 +86,5 @@ session_start(); | |||
bool(true) | |||
|
|||
Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given in %s | |||
bool(false) |
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.
Why should the feature for user defined serialized affect the return value of this method?
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.
It must return NULL because perse parameter is failing. Not sure why older code produces bool(false). I'll check it later.
The RFC was declined, closing. |
Reason for this PR is mentioned by yohgaki here: https://gist.github.com/yohgaki/432579e535ae97856a1227e4d47d0e2e class MyHandler extends SessionHandler {
function read($session_id) {
$content = parent::read($session_id);
if (!empty($content) && ($json_decode = json_decode($content, true)) !== null) {
$_SESSION = $json_decode;
return '';
}
return $content;
}
function write($session_id, $session_data) {
if (empty($_SESSION) || ($json_encode = json_encode($_SESSION, JSON_UNESCAPED_UNICODE)) === false) {
$json_encode = '';
}
return parent::write($session_id, $json_encode);
}
} Advantages of this solution:
... so I do not thing that something like suggested session_set_save_handler() is needed |
@nolimitdev Therefore, your code simply don't optimize anything without user defined serializer. |
Anyway, hacks are not good way for solutions. |
@nolimitdev I read your code again. You should read session.c before comment. |
This PR is to add user defined session serializer.
User defined session serializer can be used
This PR is required for deprecating current OO style session save handler and implement new OO style session save handler that does not have any base class. i.e. Do not create and use currently used internal save handler as base class. This will eliminate many kinds of session save handler abuses.