Skip to content

Fix "Session object destruction failed" - update - #86

Merged
dg merged 7 commits into
nette:masterfrom
luhla:master
Jun 21, 2016
Merged

Fix "Session object destruction failed" - update#86
dg merged 7 commits into
nette:masterfrom
luhla:master

Conversation

@luhla

@luhla luhla commented Mar 7, 2016

Copy link
Copy Markdown
Contributor

No description provided.

@luhla

luhla commented Mar 7, 2016

Copy link
Copy Markdown
Contributor Author

Sorry, have to study how run tests before pull request...

@hrach

hrach commented Mar 7, 2016

Copy link
Copy Markdown
Contributor

And try to fix the current one, not to open another :)

Comment thread src/Http/Session.php Outdated
throw new Nette\InvalidStateException('Cannot regenerate session ID after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.'));
}
if (session_id() !== '') {
session_write_close();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luhla Maybe the session_write_close(); should be before the if. That should fix the failing test as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try it before, but result was also failed checks. Solution is session_write_close(); before session_regenerate_id(TRUE); in my case but I wouldnt do annoing tests here.

@dg

dg commented Jun 17, 2016

Copy link
Copy Markdown
Member

Can you explain what is it good for?

@luhla

luhla commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

Getting "session_regenerate_id(): Session object destruction failed" when calling before session_write_close();
But i can`t call session_write_close(); before session_id().

@dg

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

Is it needed to call session_write_close() when session_id() === '' ?

Or now we can use http://php.net/manual/en/function.session-status.php

@luhla

luhla commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

Getting error when using:

if (session_id() !== '') {
        session_regenerate_id(TRUE);
}

Everithing fine when using:

if (session_status() === PHP_SESSION_ACTIVE ) {
        session_regenerate_id(TRUE);
}

luhla added 2 commits June 20, 2016 14:56
Change sessions state detection
readded session_write_close(); deleted by mistake
@dg

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

IMHO session_write_close(); should be in condition too.

luhla added 2 commits June 20, 2016 15:41
session_write_close moved to condition
session_write_close readded after condition
@dg

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

Did you change the order of session_write_close and session_regenerate_id intentionally?

@luhla

luhla commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

Make no sense for me, where should be session_write_close() "in condition too" ?
After session_regenerate_id(TRUE) it is unnecessary because there is another session_write_close() after condition. But it should be always before $backup = $_SESSION;
Giving session_write_close() before session_regenerate_id(TRUE) is not obviously good idea.

@dg

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

After session_regenerate_id(TRUE) it is unnecessary because there is another session_write_close() after condition

Why must be another after condition? Why call it when session is not active?

@luhla

luhla commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

Well, thats true, it might not, when seesion status is not active, nothing will be writen to session. I will fix it.

@dg
dg merged commit 80efe13 into nette:master Jun 21, 2016
@dg

dg commented Jun 21, 2016

Copy link
Copy Markdown
Member

Thanks!

@luhla

luhla commented Jun 21, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for nothing, you did the solution. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants