Set-Cookie in .htaccess kills PHP session

Just spent too much time on finding out why sessions didn’t work on a particular site. To be precise: the PHP session cookie was not sent.

Turned out that there was a line in the site’s .htaccess that also set a temporary cookie:

<FilesMatch "\.php$">
Header set Set-Cookie "myCookie=1; path=/;"
</FilesMatch>

All was fine when I changed set into add:

<FilesMatch "\.php$">
Header add Set-Cookie "myCookie=1; path=/;"
</FilesMatch>

Cheers.

Mysterious ‘headers already sent’ while handling php://input stream

A script that handled a php://input stream exited rather unexpectedly when it called session_start(). I had ‘track_errors’ enabled, so there was a message in $php_errormsg saying that headers had already been sent. But there was no file name or line number.

Continue reading Mysterious ‘headers already sent’ while handling php://input stream

Studio without Server

I’ve been using Zend Studio for many years now and think that it is a great IDE for building sites with PHP and JavaScript. IIRC I started with ZS 5; until this week I used version 9. I also ran a free Zend Server package, including Apache 2.2 and PHP 5.4. All this on an ordinary Windows 7 machine.

As my production web server now runs on Apache 2.4 and PHP 5.6, an upgrade on the dev machine seemed appropriate. Also, Zend recently launched Studio 13, with support for PHP 5.6 and even PHP 7. I decided to upgrade everything at once.

Continue reading Studio without Server

Post from server to Facebook page with FB’s PHP SDK 4

On my server, I have a PHP script that runs once a day to post a message and a picture to a Facebook page that I administer. Yesterday Facebook upgraded their API to v2, breaking my script that had been running fine since a few years.

Continue reading Post from server to Facebook page with FB’s PHP SDK 4

When the server ran out of inodes

A while ago I couldn’t add any files to a Debian server I control. It was pretty odd, as there was plenty of free disk space available (df -h will show that).

After I deleted a number of web cache files, I could add new files again. But soon the problem would return, leaving me wondering what was wrong.

Continue reading When the server ran out of inodes