FreeBSD & sessions

Disclaimer: I’m new to Yii and just started developing in PHP not too long ago (more C/C++ background), so please bear with me if this is a well known problem :)

This is a tip for anyone else running FreeBSD:

If you haven’t done so already and you’re finding that you’re running into strange blank screens when doing seemingly basic operations, make sure that you have /usr/ports/php5-extensions installed.

I was running into an issue where accessing user data via Yii::app()->user would cause nothing to be rendered after the call. As the call was being made in my first widget, I was getting a blank page (other than the body and opening div tags).

The problem turned out to be that FreeBSD doesn’t install PHP session support by default. I ended up tracking down the problem to session_start in CHttpSession.php in the framework, which was causing the blank page due to the error suppression operator (@) being used.

So the conclusion is: don’t use the “@” operator? :)

I agree - from a debugging standpoint, it’s a HUGE pain (and not anything I’d ever use in my own code). Having said that, the issue that I ran into is in part of the core Yii framework. I tried removing it (the @ operator), but it seems that it actually gets called by the framework multiple times. When it does, it causes a PHP error noting that a session has already been started. I’m not familiar enough with Yii at this point to go about changing the design to eliminate the multiple calls and I’d rather invest time into the project I’m working on rather than the framework itself ;)

dear demian,

after whole day banging my head on the wall it turns up that your post is the solution to my problem. Thank you very much of your generosity sharing with us. Thumbs up…