SF2 Session - unable to read or write - php

I keep getting an error when trying to access my sessions
PHP Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /mnt/projects/.../Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php(Line:69): Error #2 SessionHandler::read(): Session data file is not created by your uid
The session file exists, is readable and writable by apache, I have no idea what is wrong.
The session config is only:
session:
storage_id: session.storage.native
What's wrong here? I have never experienced it before. The whole SF session abstraction looks over engineered to say the least

Related

Deleting php sessions manually –> PHP throws warning

During some maintenance I have deleted the php user session files. This lead to a behavior that I do not understand. php began to throw errors like this:
PHP Warning: Unknown: open(/tmp/sessions/sess_xxxxxxxxxxxxxxxxx, O_RDWR) failed: Permission denied (13)
I assume that when a user with an old session cookie visits the website, session_start() tries to load the session file but can not find any. The "permission denied" is a bit misleading (the session path is valid and with the right rights).
If the user deletes their browser cookies, everything works again.
My questions: Why does PHP throw a warning in case it can not find the session file? sessions files are cleaned by php regularly, so if a user simply has not been visiting for some time, the cookie might still be transmitted but no session file might be present. But in that case it seems that the warning is not triggered.
How can I prevent PHP to not stop script execution when a warning is issued (rather than a fatal error)?

Duplicate entries in PHP error_log using set_exception_handler

I cannot seem to locate the source of this issue. I actually have nearly the same Docker container and Exception handler lib running in another app. However, for some reason, I'm getting duplicate log entries in the error log file.
The issue is that it's not just duplicate entries that are the same (that'd be another interesting issue). It's the same Exception being logged and the same stack trace, but one is from my custom Exception handler (JSON), and the other is the default PHP error log handler (or so it seems - tested with CLI SAPI as well as PHP-FPM).
I was under the assumption that PHP wouldn't write to the log file if an exception handler was set. I'm also executing die(1) at the end of the callback function for the Exception handler.
Again, all of the Exception handling code seems to be working well. It's just that PHP is still logging the Exception. Is there a setting or something else that I'm missing here needing to be done on the PHP config side?
Below is a copy of the error log output:
[24-Nov-2018 02:20:11 UTC] PHP Exception: Testing in /srv/www/boot/common.php on line 65
[24-Nov-2018 02:20:11 UTC] PHP Stack trace:
[24-Nov-2018 02:20:11 UTC] PHP 1. {main}() /srv/www/public/index.php:0
[24-Nov-2018 02:20:11 UTC] PHP 2. require() /srv/www/public/index.php:13
{"timestamp":"2018-11-24 02:20:11 UTC","level":"critical","message":"Testing","app_version":{},"environment":"dev","class":"Exception","file":"\/srv\/www\/boot\/common.php","line":65,"code":0,"previous":null,"trace":[{"file":"\/srv\/www\/public\/index.php","line":13,"function":"require"}],"user":[],"tags":[],"extra":[],"output_buffers":[]}
Going to leave this here for anyone that might come across this. The issue turned out to be XDebug which hijacks your Exceptions. It was enabled on this particular app in our dev env.

Errors destroying and reading sessions in PHP

I have a PHP 7 app that works well on all servers it's installed on except one. All servers are Windows (I believe server 2008 R2 and 2012). The problem is that on one of the servers, we keep getting two kinds of errors sporadically, seemingly randomly. One of the errors is
session_destroy(): Session object destruction failed
and the other is
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Unknown: open(E:\tmp\sess_6qlo69vbii0qs65i4n47blafi3, O_RDWR) failed: Permission denied (13)' in Unknown:0
Every search I do on these errors go back to permissions, which makes sense aside from the fact that it's not happening every time, it's random. What am I missing here, could anything cause the permissions on the file to be different when the session gets created for some reason in certain situations? Or anything else that could possibly explain this behavior?

Zend project hosting session issues

I'm hosting a Zend project in the server. After solving some .htaccess problems now I'm facing session issues.
this is the error i see :
exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /home/*/public_html///library/Zend/Session.php(Line:477): Error #2 session_start() [function.session-start]: open(/tmp/sci/sess_0c949aecb59cfcaa46f46dd45ab9313a, O_RDWR) failed: No such file or directory (2) /home/*/public_html///library/Zend/Session.php(Line:487): Error #2 session_write_close()
/tmp/sci/ is an existing folder but i can't see any session file inside it. It seems to me, that Zend is trying to look for a session file form a session id which is not already created.
Help much appreciated.

Zend session_start gives Fatal error: Exception thrown without a stack frame in Unknown on line 0

When running a Zend application locally I get Fatal error: Exception thrown without a stack frame in Unknown on line 0, i traced that error to a line $startedCleanly = session_start();
I can't get through it, when I restart the server and reload the page I do not get the error, but on every other reload I get it, I looked into a php/tmp dir too see if there are any files, and as I see they aren't there. I think that session isn't written but when I try just a simple test.php file with session_start(); line, without zend framework, I see that there is a file created in that dir.
I really don't know where to go next.
Happens when your destructor or error handler throws an exception. That can happen for multiple reasons depending on your exact setup and method for session storage you're using. For example the session directory is not writeable or does not exist, database is not accessible or fields are invalid, redis does not respond, etc.
So, check your settings and look for something that would prevent saving the session data.
More elaborate description can be found here.
I know this post is old, but I've just figured out that I was getting "Fatal error: Exception thrown without a stack frame in Unknown on line 0" because my 'modified' and 'lifetime' columns were of type 'timestamp without time zone' when they should have been 'integer' (I'm using Postgres 9 BTW)
Hope this helps someone.
The problem could also be a disk full problem !!!

Categories