Forget Me Not: PHP Sessions Should Be Started First

I’m sure I’ll continue to forget this, since this is the third or so time it’s happened to me, but I’m going to leave a note for later anyway. Maybe this will make it more obvious to myself. 🙂

If you’re experiencing weird/broken stuff with your PHP SESSION variables, and if you check the error log and see a message about headers….

Warning: session_start(): Cannot send session cookie – headers already sent by

… then you are starting your session after some kind of output has already been sent to the user. For the visual example, take a look at the following before smacking your forehead. The first example is correct, the second is probably wrong.


session_start();
include ('header.php');

———

include ('header.php');
session_start();

Consider myself reminded. That is all.

TopTwit.Com Launched

I was slightly bored yesterday and slightly interested when I ran into twitter.alltop.com. Alltop was interesting, but it would be great if there was a fully customizable version (at least for Twitter) that let you decide which people you wanted on your page so you could browse their last 5 tweets. Robert Scoble said the same thing in a twitter/friendfeed post the other day, so I figured there was probably some demand for it. If the king of noise is looking for something to provide more noise, why not give it to him.

I immediately got to work, registered the domain, and pounded out the site. [1] TopTwit.com is the result of that work. It’s fairly basic right now, but pretty easy as well. You can sign up for an account, add the Twitter users that you want to follow, and then go to the [1] front page and browse through each user’s last 5 tweets to the world.

A full writeup explaining everything is available on my TopTwit page. Please comment there or here with any feedback that you have. I’ll be adding more features and tweaking throughout the week.

[1] removed link to toptwit.com as this project is dead and I am no longer the owner of the domain.

Godaddy Vs. WordPress 2.5.1 – htaccess

This is more of a reminder to myself than anything else, but WordPress was running slow as hell when I first installed it. After a couple hours and a bunch of page reloading while trying to configure everything, I ran into a 500 internal server error roadblock and couldn’t get anything to come up anymore at all.

Thanks to Google, I ran into this forum post right away, from which I gathered (without reading too deeply)– Godaddy’s PHP5 needs to be told to use itself or something, so I added this code to the .htaccess file:

AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

Seems to be working fine again, and it’s quick, quick, quick.