Cookies with PHP’s setcookie() and Safari

I’ve come across a little inconsistency between browsers and the way they handle cookies. Using the examples from PHP’s online manual, I was unable to get Safari to remove cookies using setcookie(). All other browsers would clear the cookie with no problems. It turns out that Safari will only delete cookies if both the cookie name AND the cookie path match.

In other words, this won’t work:

setcookie('TestCookie', 'somevalue', time()+3600, '/somepath/'); // Set cookie
setcookie('TestCookie', '', time()-3600); // Delete cookie

But this will work:

setcookie('TestCookie', 'somevalue', time()+3600, '/somepath/'); // Set cookie
setcookie('TestCookie', '', time()-3600, '/somepath/'); // Delete cookie

Basically, if you set a cookie using a path, you must also specify the path when deleting the cookie. Safari won’t remove the cookie otherwise. This is probably a good thing.

Squirrelmail and Very Large (Big-Ass) Inboxes

We have an account with a VERY large inbox (over 80,000 emails), and when logging into Squirrelmail the main pane would not load. Instead we’d be prompted by the browser to download a right_main.php file. Accounts with smaller inboxes would load fine, so I figured it had something to do with system resources. This is an easy fix. Open up your php.ini file, and increase the memory_limit value to something larger than the default 8M. Restart Apache and try opening your big-ass inbox again. If it still doesn’t work, increase memory_limit again. Repeat until your inbox will load, but be careful if you have little RAM. I was able to load my 80,000+ inbox by setting memory_limit = 32M.

Installing PDFlib Lite as a PHP module on Fedora Core 4

The instructions for doing so (here) seemed straightforward enough, but I ran into a few problems. So here’s how I got PDFLib working with my PHP install on Fedora Core 4.

First we need to build PDFlib Lite from Source. Download it from here. Unpack it, then:
./configure
make
make install

Easy enough. Now:
yum install automake
yum install php-devel
pecl install pdflib

(Note: php-devel is required because we need phpize which is used by the pecl command.)

The PECL install will ask you a question: “Path to PDFlib installation?” This is where I ran into problems. You must put /usr/local/ and NOT /usr/local/include because the script is hardcoded to look inside the include directory automatically. Once PECL finds pdflib.h it will continue and finish compiling our shared object, pdf.so. The script will install it for us in /usr/lib/php/modules/
Now we just have to tell PHP to load the SO. Open up php.ini and add the following line:
extension=pdf.so
Save & exit, and restart your Apache with apachectl graceful. Now browse to a file containing the phpinfo() function and check to see if PDFlib is now active. If you see it, you’re good to go!

NOTE: I ran into a problem with RPM GPG Keys at the automake install step. I was getting the following error:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID db42a60e
public key not available for autoconf-2.59-5.noarch.rpm
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
The GPG key at file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora (0x4F2A6FD2)
is already installed but is not the correct key for this package.
Check that this is the correct key for the "Fedora Core 4 - i386 - Base" repository.

To get around this we need to import all the keys by run the following command:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
I found this solution in this thread.

Xdebug & phpize for PHP on FreeBSD

I ran into a few problems trying to install Xdebug into PHP on both FreeBSD 5.2 and FreeBSD 5.4. My research led me to this PHP bug thread and the proper solution. Here’s a quick summary to get you going with Xdebug:

Xdebug is installed via phpize, and phpize has some requirements:

  • autoconf: 2.13
  • automake: 1.4+
  • libtool: 1.4.x+ (except 1.4.2)
  • bison: 1.28 (preferred), 1.35, or 1.75
  • flex: 2.5.4

I was able to get mine up and running with the following versions:

  • autoconf: 2.59_2
  • automake: 1.9.5
  • libtool: 1.5.10_1
  • bison: 1.75_2
  • flex: 2.5.4

However, the ports packages for autoconf, automake, and libtool that come with FreeBSD are installed into non-standard locations, so phpize is unable to find them. This is easily fixed with symlinks (NOTE: symlinks will vary depending on which versions you have installed):
ln -s /usr/local/bin/aclocal19 /usr/local/bin/aclocal
ln -s /usr/local/bin/automake19 /usr/local/bin/automake
ln -s /usr/local/bin/autoconf259 /usr/local/bin/autoconf
ln -s /usr/local/bin/autoheader259 /usr/local/bin/autoheader
ln -s /usr/local/bin/libtool15 /usr/local/bin/libtool
ln -s /usr/local/bin/libtoolize15 /usr/local/bin/libtoolize
ln -s /usr/local/share/aclocal19/ /usr/local/share/aclocal
ln -s /usr/local/share/aclocal19/libtool15.m4 /usr/local/share/aclocal19/libtool.m4

Now, assuming you have all the correct versions installed and paths present, phpize should be able to find everything and Xdebug should install as expected:
# phpize
# ./configure --enable-xdebug
# make
# cp modules/xdebug.so /usr/local/lib/php/extensions

  • Add the following to php.ini:
    zend_extension="/usr/local/lib/php/extensions/xdebug.so"
  • Restart your webserver
  • Check the output of phpinfo() to make sure Xdebug is properly loaded